import warnings
warnings.filterwarnings('ignore')
import os 
import pandas as pd
import numpy as np
from numpy import abs
from numpy import log
from numpy import sign
import sys 
import akshare as ak
from feature_eng.alpha_101.ind_utlity import *


class Alphas_ind(object):
    def __init__(self):
        self.open = self.get_df_data('open') 
        self.high = self.get_df_data('high') 
        self.low = self.get_df_data('low')   
        self.close = self.get_df_data('close') 
        self.volume = self.get_df_data('volume')
        self.returns = np.log(self.close/self.close.shift(1)) 
        self.vwap = self.get_df_data('amount')/self.volume 
        self.cap = self.get_df_data('total_mv')
        self.get_bencheck()

    def get_df_data(self, name) :
        root = r'data\stock_data\daily\consentrate_price'
        file = os.path.join(root, f'{name}.pkl.gzip')
        data = pd.read_pickle(file)
        return data

    def get_bencheck(self):
        hs300  = ak.stock_zh_index_daily(symbol="sh000001")
        hs300.index = pd.to_datetime(hs300['date'].values)
        hs300oc = hs300[['open','close']].astype(float)
        hs300oc = hs300oc[hs300oc.index>'2001-1-01']
        # hs300oc.loc[self.close.index[-1]] = [0,0]
        self.benchmark_close = pd.DataFrame(np.expand_dims(hs300oc['close'], axis=1)*np.ones(self.close.shape), index=self.close.index, columns=self.close.columns)
        self.benchmark_open = pd.DataFrame(np.expand_dims(hs300oc['open'], axis=1)*np.ones(self.close.shape), index=self.close.index, columns=self.close.columns)


# Alpha#48	 (indneutralize(((correlation(delta(self.close, 1), delta(delay(self.close, 1), 1), 250) *delta(self.close, 1)) / close)) / ts_sum(((delta(self.close, 1) / delay(self.close, 1))^2), 250))
    def alpha_n0(self):
        return indneutralize(((correlation(delta(self.close, 1), delta(delay(self.close, 1), 1), 250) *delta(self.close, 1)) / self.close)) / ts_sum(np.power((delta(self.close, 1) / delay(self.close, 1)),2), 250)

# Alpha#58	 (-1 * ts_rank(decay_linear(correlation(indneutralize(self.vwap), volume,3.92795), 7.89291), 5.50322))
    def alpha_n1(self):
        return -1 * ts_rank(decay_linear(correlation(indneutralize(self.vwap), self.volume, 4), 8), 6)

# Alpha#59	 (-1 * ts_rank(decay_linear(correlation(indneutralize(((self.vwap * 0.728317) + (self.vwap *(1 - 0.728317)))), volume, 4.25197), 16.2289), 8.19648))
    def alpha_n2(self):
        return -1 * ts_rank(decay_linear(correlation(indneutralize(self.vwap), self.volume, 4), 16), 8)

# Alpha#63	 ((rank(decay_linear(delta(indneutralize(self.close), 2.25164), 8.22237))- rank(decay_linear(correlation(((self.vwap * 0.318108) + (self.open * (1 - 0.318108))), ts_sum(adv180,37.2467), 13.557), 12.2883))) * -1)
    def alpha_n3(self):
        adv180 = Mean(self.volume, 180)
        return (rank(decay_linear(delta(indneutralize(self.close), 3), 8))- rank(decay_linear(correlation(((self.vwap * 0.318108) + (self.open * (1 - 0.318108))), ts_sum(adv180,37), 14), 12))) * -1

# Alpha#67	 ((rank((self.high - ts_min(self.high, 2.14593)))^rank(correlation(indneutralize(self.vwap), indneutralize(adv20), 6.02936))) * -1)
    def alpha_n4(self):
        adv20 = Mean(self.volume, 20)
        return (np.power(rank((self.high - ts_min(self.high, 3))),rank(correlation(indneutralize(self.vwap), indneutralize(adv20), 6)))) * -1

# Alpha#69	 ((rank(ts_max(delta(indneutralize(self.vwap), 2.72412),4.79344))^ts_rank(correlation(((self.close * 0.490655) + (self.vwap * (1 - 0.490655))), adv20, 4.92416),9.0615)) * -1)
    def alpha_n5(self): 
        adv20 = Mean(self.volume, 20)
        return (np.power(rank(ts_max(delta(indneutralize(self.vwap), 3),5)),ts_rank(correlation(((self.close * 0.490655) + (self.vwap * (1 - 0.490655))), adv20, 5),9))) * -1

# Alpha#70	 ((rank(delta(self.vwap, 1.29456))^ts_rank(correlation(indneutralize(self.close), adv50, 17.8256), 17.9171)) * -1)
    def alpha_n6(self):
        adv50 = Mean(self.volume, 50)
        return (np.power(rank(delta(self.vwap, 1)),ts_rank(correlation(indneutralize(self.close), adv50, 18), 18))) * -1

# Alpha#76	 (np.maximum(rank(decay_linear(delta(self.vwap, 1.24383), 11.8259)),ts_rank(decay_linear(ts_rank(correlation(indneutralize(self.low), adv81,8.14941), 19.569), 17.1543), 19.383)) * -1)
    def alpha_n7(self):
        adv81 = Mean(self.volume, 81)
        return np.maximum(rank(decay_linear(delta(self.vwap, 1), 12)),ts_rank(decay_linear(ts_rank(correlation(indneutralize(self.low), adv81,8), 20), 17), 19)) * -1

# Alpha#79	 (rank(delta(indneutralize(((self.close * 0.60733) + (self.open * (1 - 0.60733)))), 1.23438)) < rank(correlation(ts_rank(self.vwap, 3.60973), ts_rank(adv150,9.18637), 14.6644)))
    def alpha_n8(self):
        adv150 = Mean(self.volume, 150)
        return rank(delta(indneutralize(((self.close * 0.60733) + (self.open * (1 - 0.60733)))), 1)) < rank(correlation(ts_rank(self.vwap, 4), ts_rank(adv150,9), 15))

# Alpha#80	 ((rank(sign(delta(indneutralize(((self.open * 0.868128) + (self.high * (1 - 0.868128)))), 4.04545)))^ts_rank(correlation(self.high, adv10, 5.11456), 5.53756)) * -1)
    def alpha_n9(self):
        adv10 = Mean(self.volume, 10)
        return np.power(rank(np.sign(delta(indneutralize(((self.open * 0.868128) + (self.high * (1 - 0.868128)))), 4))),ts_rank(correlation(self.high, adv10, 5), 6)) * -1

# Alpha82	 (np.minimum(rank(decay_linear(delta(self.open, 1.46063), 14.8717)),ts_rank(decay_linear(correlation(indneutralize(self.volume), ((self.open * 0.634196) +(self.open * (1 - 0.634196))), 17.4842), 6.92131), 13.4283)) * -1)
    def alpha_n10(self):
        return np.minimum(rank(decay_linear(delta(self.open, 1), 15)),ts_rank(decay_linear(correlation(indneutralize(self.volume), self.open, 17), 7), 13)) * -1

# Alpha#87	 (np.maximum(rank(decay_linear(delta(((self.close * 0.369701) + (self.vwap * (1 - 0.369701))),1.91233), 2.65461)), ts_rank(decay_linear(abs(correlation(indneutralize(adv81), close, 13.4132)), 4.89768), 14.4535)) * -1)
    def alpha_n11(self):  
        adv81 = Mean(self.volume, 81)
        return np.maximum(rank(decay_linear(delta(((self.close * 0.369701) + (self.vwap * (1 - 0.369701))),2), 3)), ts_rank(decay_linear(abs(correlation(indneutralize(adv81), self.close, 13)), 5), 14)) * -1


# Alpha#89	 (ts_rank(decay_linear(correlation(((self.low * 0.967285) + (self.low * (1 - 0.967285))), adv10,6.94279), 5.51607), 3.79744) - ts_rank(decay_linear(delta(indneutralize(self.vwap), 3.48158), 10.1466), 15.3012))
    def alpha_n12(self): 
        adv10 = Mean(self.volume, 10)
        return ts_rank(decay_linear(correlation(self.low, adv10,7), 6), 4) - ts_rank(decay_linear(delta(indneutralize(self.vwap), 3), 10), 15)


# Alpha#90	 ((rank((self.close - ts_max(self.close, 4.66719)))^ts_rank(correlation(indneutralize(adv40), low, 5.38375), 3.21856)) * -1)
    def alpha_n13(self):
        adv40 = Mean(self.volume, 40)
        return (np.power(rank((self.close - ts_max(self.close, 5))),ts_rank(correlation(indneutralize(adv40), self.low, 5), 3))) * -1


# Alpha#91	 ((ts_rank(decay_linear(decay_linear(correlation(indneutralize(self.close), volume, 9.74928), 16.398), 3.83219), 4.8667) -rank(decay_linear(correlation(self.vwap, adv30, 4.01303), 2.6809))) * -1)
    def alpha_n14(self):
        adv30 = Mean(self.volume, 30)
        return (ts_rank(decay_linear(decay_linear(correlation(indneutralize(self.close), self.volume, 10), ), 4), 5) -rank(decay_linear(correlation(self.vwap, adv30, 4), 3))) * -1

# Alpha#93	 (ts_rank(decay_linear(correlation(indneutralize(self.vwap), adv81,17.4193), 19.848), 7.54455) / rank(decay_linear(delta(((self.close * 0.524434) + (self.vwap * (1 -0.524434))), 2.77377), 16.2664)))
    def alpha_n15(self):
        adv81 = Mean(self.volume, 81)
        return ts_rank(decay_linear(correlation(indneutralize(self.vwap), adv81,17), 20), 8) / rank(decay_linear(delta(((self.close * 0.524434) + (self.vwap * (1 -0.524434))), 3), 16))

# Alpha#97	 ((rank(decay_linear(delta(indneutralize(((self.low * 0.721001) + (self.vwap * (1 - 0.721001)))), 3.3705), 20.4523)) - ts_rank(decay_linear(ts_rank(correlation(ts_rank(self.low,7.87871), ts_rank(adv60, 17.255), 4.97547), 18.5925), 15.7152), 6.71659)) * -1)
    def alpha_n16(self):
        adv60 = Mean(self.volume, 60)
        return (rank(decay_linear(delta(indneutralize(((self.low * 0.721001) + (self.vwap * (1 - 0.721001)))), 3), 20)) - ts_rank(decay_linear(ts_rank(correlation(ts_rank(self.low,8), ts_rank(adv60, 17), 5), 19), 16), 7)) * -1

# Alpha#100	 (0 - (1 * (((1.5 * scale(indneutralize(indneutralize(rank(((((self.close - low) - (self.high -close)) / (self.high - low)) * volume)))))) -scale(indneutralize((correlation(self.close, rank(adv20), 5) - rank(ts_argnp.minimum(self.close, 30)))))) * (self.volume / adv20))))
    def alpha_n17(self):
        adv20 = Mean(self.volume, 20)
        return 0 - (1 * (((1.5 * scale(indneutralize(indneutralize(rank(((((self.close - self.low) - (self.high -self.close)) / (self.high - self.low)) * self.volume)))))) -scale(indneutralize((correlation(self.close, rank(adv20), 5) - rank(ts_argmin(self.close, 30)))))) * (self.volume / adv20)))

    def alpha_n18(self):
       return (0 - (1 * (rank((Mean(self.returns, 10) / Mean(Mean(self.returns, 2), 3))) * rank((self.returns * self.cap)))))

    # Alpha#1	 (rank(Ts_ArgMax(SignedPower(((returns < 0) ? stddev(returns, 20) : close), 2.), 5)) -0.5)
    def alpha_n19(self):
        inner = self.close
        inner[self.returns < 0] = stddev(self.returns, 20)
        return rank(ts_argmax(inner ** 2, 5))
    
    # Alpha#20	 (((-1 * rank((open - delay(high, 1)))) * rank((open - delay(close, 1)))) * rank((open -delay(low, 1))))
    def alpha_n20(self):
        return -1 * (rank(self.open - delay(self.high, 1)) *
                     rank(self.open - delay(self.close, 1)) *
                     rank(self.open - delay(self.low, 1)))

    # Alpha#21	 ((((ts_sum(close, 8) / 8) + stddev(close, 8)) < (ts_sum(close, 2) / 2)) ? (-1 * 1) : (((ts_sum(close,2) / 2) < ((ts_sum(close, 8) / 8) - stddev(close, 8))) ? 1 : (((1 < (volume / adv20)) || ((volume /adv20) == 1)) ? 1 : (-1 * 1))))
    def alpha_n21(self):
        cond_1 = Mean(self.close, 8) + stddev(self.close, 8) < Mean(self.close, 2)
        cond_2 = Mean(self.volume, 20) / self.volume < 1
        alpha = pd.DataFrame(np.ones_like(self.close), index=self.close.index
                             )
#        alpha = pd.DataFrame(np.ones_like(self.close), index=self.close.index,
#                             columns=self.close.columns)
        alpha[cond_1 | cond_2] = -1
        return alpha
    
    # Alpha#22	 (-1 * (delta(correlation(high, volume, 5), 5) * rank(stddev(close, 20))))
    def alpha_n22(self):
        df = correlation(self.high, self.volume, 5)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return -1 * delta(df, 5) * rank(stddev(self.close, 20))

    # Alpha#23	 (((ts_sum(high, 20) / 20) < high) ? (-1 * delta(high, 2)) : 0)
    # def alpha_n23(self):
    #     cond = Mean(self.high, 20) < self.high
    #     alpha = pd.DataFrame(np.zeros_like(self.close),index=self.close.index,columns=['close'])
    #     alpha.at[cond,'close'] = -1 * delta(self.high, 2).fillna(value=0)
    #     return alpha
    
    # Alpha#24	 ((((delta((ts_sum(close, 100) / 100), 100) / delay(close, 100)) < 0.05) ||((delta((ts_sum(close, 100) / 100), 100) / delay(close, 100)) == 0.05)) ? (-1 * (close - ts_min(close,100))) : (-1 * delta(close, 3)))
    def alpha_n24(self):
        cond = delta(Mean(self.close, 100), 100) / delay(self.close, 100) <= 0.05
        alpha = -1 * delta(self.close, 3)
        alpha[cond] = -1 * (self.close - ts_min(self.close, 100))
        return alpha
    
    # Alpha#25	 rank(((((-1 * returns) * adv20) * vwap) * (high - close)))
    def alpha_n25(self):
        adv20 = Mean(self.volume, 20)
        return rank(((((-1 * self.returns) * adv20) * self.vwap) * (self.high - self.close)))
    
    # Alpha#26	 (-1 * ts_max(correlation(ts_rank(volume, 5), ts_rank(high, 5), 5), 3))
    def alpha_n26(self):
        df = correlation(ts_rank(self.volume, 5), ts_rank(self.high, 5), 5)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return -1 * ts_max(df, 3)
    
    # Alpha#27	 ((0.5 < rank((ts_sum(correlation(rank(volume), rank(vwap), 6), 2) / 2.0))) ? (-1 * 1) : 1)
    ###
    ## Some Error, still fixing!!
    def alpha_n27(self):
        alpha = rank((Mean(correlation(rank(self.volume), rank(self.vwap), 6), 2) / 2.0))
        alpha[alpha > 0.5] = -1
        alpha[alpha <= 0.5]=1
        return alpha  
    
    # Alpha#28	 scale(((correlation(adv20, low, 5) + ((high + low) / 2)) - close))
    def alpha_n28(self):
        adv20 = Mean(self.volume, 20)
        df = correlation(adv20, self.low, 5)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return scale(((df + ((self.high + self.low) / 2)) - self.close))

    # Alpha#29	 (min(product(rank(rank(scale(log(ts_sum(ts_min(rank(rank((-1 * rank(delta((close - 1),5))))), 2), 1))))), 1), 5) + ts_rank(delay((-1 * returns), 6), 5))
    def alpha_n29(self):
        return (ts_min(rank(rank(scale(log(ts_sum(rank(rank(-1 * rank(delta((self.close - 1), 5)))), 2))))), 5) +
                ts_rank(delay((-1 * self.returns), 6), 5))

    # Alpha#30	 (((1.0 - rank(((sign((close - delay(close, 1))) + sign((delay(close, 1) - delay(close, 2)))) +sign((delay(close, 2) - delay(close, 3)))))) * ts_sum(volume, 5)) / ts_sum(volume, 20))
    def alpha_n30(self):
        delta_close = delta(self.close, 1)
        inner = sign(delta_close) + sign(delay(delta_close, 1)) + sign(delay(delta_close, 2))
        return ((1.0 - rank(inner)) * ts_sum(self.volume, 5)) / ts_sum(self.volume, 20)

    # Alpha#31	 ((rank(rank(rank(decay_linear((-1 * rank(rank(delta(close, 10)))), 10)))) + rank((-1 *delta(close, 3)))) + sign(scale(correlation(adv20, low, 12))))
    def alpha_n31(self):
        adv20 = Mean(self.volume, 20)
        df = correlation(adv20, self.low, 12).replace([-np.inf, np.inf], 0).fillna(value=0)         
        p1=rank(rank(rank(decay_linear((-1 * rank(rank(delta(self.close, 10)))), 10)))) 
        p2=rank((-1 * delta(self.close, 3)))
        p3=sign(scale(df))
        
        return p1+p2+p3

    # Alpha#32	 (scale(((ts_sum(close, 7) / 7) - close)) + (20 * scale(correlation(vwap, delay(close, 5),230))))
    def alpha_n32(self):
        return scale(((Mean(self.close, 7) / 7) - self.close)) + (20 * scale(correlation(self.vwap, delay(self.close, 5),230)))
    
    # Alpha#33	 rank((-1 * ((1 - (open / close))^1)))
    def alpha_n33(self):
        return rank(-1 + (self.open / self.close))
    
    # Alpha#34	 rank(((1 - rank((stddev(returns, 2) / stddev(returns, 5)))) + (1 - rank(delta(close, 1)))))
    def alpha_n34(self):
        inner = stddev(self.returns, 2) / stddev(self.returns, 5)
        inner = inner.replace([-np.inf, np.inf], 1).fillna(value=1)
        return rank(2 - rank(inner) - rank(delta(self.close, 1)))

    # Alpha#35	 ((Ts_rank(volume, 32) * (1 - Ts_rank(((close + high) - low), 16))) * (1 -Ts_rank(returns, 32)))
    def alpha_n35(self):
        return ((ts_rank(self.volume, 32) *
                 (1 - ts_rank(self.close + self.high - self.low, 16))) *
                (1 - ts_rank(self.returns, 32)))
            
    # Alpha#36	 (((((2.21 * rank(correlation((close - open), delay(volume, 1), 15))) + (0.7 * rank((open- close)))) + (0.73 * rank(Ts_rank(delay((-1 * returns), 6), 5)))) + rank(abs(correlation(vwap,adv20, 6)))) + (0.6 * rank((((ts_sum(close, 200) / 200) - open) * (close - open)))))
    def alpha_n36(self):
        adv20 = Mean(self.volume, 20)
        return (((((2.21 * rank(correlation((self.close - self.open), delay(self.volume, 1), 15))) + (0.7 * rank((self.open- self.close)))) + (0.73 * rank(ts_rank(delay((-1 * self.returns), 6), 5)))) + rank(abs(correlation(self.vwap,adv20, 6)))) + (0.6 * rank((((Mean(self.close, 200) / 200) - self.open) * (self.close - self.open)))))
    
    # Alpha#37	 (rank(correlation(delay((open - close), 1), close, 200)) + rank((open - close)))
    def alpha_n37(self):
        return rank(correlation(delay(self.open - self.close, 1), self.close, 200)) + rank(self.open - self.close)
    
    # Alpha#38	 ((-1 * rank(Ts_rank(close, 10))) * rank((close / open)))
    def alpha_n38(self):
        inner = self.close / self.open
        inner = inner.replace([-np.inf, np.inf], 1).fillna(value=1)
        return -1 * rank(ts_rank(self.open, 10)) * rank(inner)
    
    # Alpha#39	 ((-1 * rank((delta(close, 7) * (1 - rank(decay_linear((volume / adv20), 9)))))) * (1 +rank(ts_sum(returns, 250))))
    def alpha_n39(self):
        adv20 = Mean(self.volume, 20)
        return ((-1 * rank(delta(self.close, 7) * (1 - rank(decay_linear((self.volume / adv20), 9))))) *
                (1 + rank(Mean(self.returns, 250))))
    
    # Alpha#40	 ((-1 * rank(stddev(high, 10))) * correlation(high, volume, 10))
    def alpha_n40(self):
        return -1 * rank(stddev(self.high, 10)) * correlation(self.high, self.volume, 10)

    # Alpha#41	 (((high * low)^0.5) - vwap)
    def alpha_n41(self):
        return pow((self.high * self.low),0.5) - self.vwap
    
    # Alpha#42	 (rank((vwap - close)) / rank((vwap + close)))
    def alpha_n42(self):
        return rank((self.vwap - self.close)) / rank((self.vwap + self.close))
        
    # Alpha#43	 (ts_rank((volume / adv20), 20) * ts_rank((-1 * delta(close, 7)), 8))
    def alpha_n43(self):
        adv20 = Mean(self.volume, 20)
        return ts_rank(self.volume / adv20, 20) * ts_rank((-1 * delta(self.close, 7)), 8)

    # Alpha#44	 (-1 * correlation(high, rank(volume), 5))
    def alpha_n44(self):
        df = correlation(self.high, rank(self.volume), 5)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return -1 * df

    # Alpha#45	 (-1 * ((rank((ts_sum(delay(close, 5), 20) / 20)) * correlation(close, volume, 2)) *rank(correlation(ts_sum(close, 5), ts_sum(close, 20), 2))))
    def alpha_n45(self):
        df = correlation(self.close, self.volume, 2)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return -1 * (rank(Mean(delay(self.close, 5), 20)) * df *
                     rank(correlation(ts_sum(self.close, 5), ts_sum(self.close, 20), 2)))
    
    # Alpha#46	 ((0.25 < (((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10))) ?(-1 * 1) : (((((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10)) < 0) ? 1 :((-1 * 1) * (close - delay(close, 1)))))
    def alpha_n46(self):
        inner = ((delay(self.close, 20) - delay(self.close, 10)) / 10) - ((delay(self.close, 10) - self.close) / 10)
        alpha = (-1 * delta(self.close))
        alpha[inner < 0] = 1
        alpha[inner > 0.25] = -1
        return alpha

    # Alpha#47	 ((((rank((1 / close)) * volume) / adv20) * ((high * rank((high - close))) / (ts_sum(high, 5) /5))) - rank((vwap - delay(vwap, 5))))
    def alpha_n47(self):
        adv20 = Mean(self.volume, 20)
        return ((((rank((1 / self.close)) * self.volume) / adv20) * ((self.high * rank((self.high - self.close))) / (Mean(self.high, 5) /5))) - rank((self.vwap - delay(self.vwap, 5))))
    
    # Alpha#48	 (indneutralize(((correlation(delta(close, 1), delta(delay(close, 1), 1), 250) *delta(close, 1)) / close), IndClass.subindustry) / ts_sum(((delta(close, 1) / delay(close, 1))^2), 250))
     
    
    # Alpha#49	 (((((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10)) < (-1 *0.1)) ? 1 : ((-1 * 1) * (close - delay(close, 1))))
    def alpha_n49(self):
        inner = (((delay(self.close, 20) - delay(self.close, 10)) / 10) - ((delay(self.close, 10) - self.close) / 10))
        alpha = (-1 * delta(self.close))
        alpha[inner < -0.1] = 1
        return alpha
    
    # Alpha#50	 (-1 * ts_max(rank(correlation(rank(volume), rank(vwap), 5)), 5))
    def alpha_n50(self):
        return (-1 * ts_max(rank(correlation(rank(self.volume), rank(self.vwap), 5)), 5))
    
    # Alpha#51	 (((((delay(close, 20) - delay(close, 10)) / 10) - ((delay(close, 10) - close) / 10)) < (-1 *0.05)) ? 1 : ((-1 * 1) * (close - delay(close, 1))))
    def alpha_n51(self):
        inner = (((delay(self.close, 20) - delay(self.close, 10)) / 10) - ((delay(self.close, 10) - self.close) / 10))
        alpha = (-1 * delta(self.close))
        alpha[inner < -0.05] = 1
        return alpha
    
    # Alpha#52	 ((((-1 * ts_min(low, 5)) + delay(ts_min(low, 5), 5)) * rank(((ts_sum(returns, 240) -ts_sum(returns, 20)) / 220))) * ts_rank(volume, 5))
    def alpha_n52(self):
        return (((-1 * delta(ts_min(self.low, 5), 5)) *
                 rank(((ts_sum(self.returns, 240) - ts_sum(self.returns, 20)) / 220))) * ts_rank(self.volume, 5))
        
    # Alpha#53	 (-1 * delta((((close - low) - (high - close)) / (close - low)), 9))
    def alpha_n53(self):
        inner = (self.close - self.low).replace(0, 0.0001)
        return -1 * delta((((self.close - self.low) - (self.high - self.close)) / inner), 9)

    # Alpha#54	 ((-1 * ((low - close) * (open^5))) / ((low - high) * (close^5)))
    def alpha_n54(self):
        inner = (self.low - self.high).replace(0, -0.0001)
        return -1 * (self.low - self.close) * (self.open ** 5) / (inner * (self.close ** 5))

    # Alpha#55	 (-1 * correlation(rank(((close - ts_min(low, 12)) / (ts_max(high, 12) - ts_min(low,12)))), rank(volume), 6))
    def alpha_n55(self):
        divisor = (ts_max(self.high, 12) - ts_min(self.low, 12)).replace(0, 0.0001)
        inner = (self.close - ts_min(self.low, 12)) / (divisor)
        df = correlation(rank(inner), rank(self.volume), 6)
        return -1 * df.replace([-np.inf, np.inf], 0).fillna(value=0)

    # Alpha#56	 (0 - (1 * (rank((ts_sum(returns, 10) / ts_sum(ts_sum(returns, 2), 3))) * rank((returns * cap)))))
    # This Alpha uses the Cap, however I have not acquired the data yet
    # def alpha_n56(self):
    #    return (0 - (1 * (rank((Mean(self.returns, 10) / Mean(Mean(self.returns, 2), 3))) * rank((self.returns * self.cap)))))
    
    # Alpha#57	 (0 - (1 * ((close - vwap) / decay_linear(rank(ts_argmax(close, 30)), 2))))
    def alpha_n57(self):
        return (0 - (1 * ((self.close - self.vwap) / decay_linear(rank(ts_argmax(self.close, 30)), 2))))
    
    # Alpha#58	 (-1 * Ts_rank(decay_linear(correlation(IndNeutralize(vwap, IndClass.sector), volume,3.92795), 7.89291), 5.50322))
     
    # Alpha#59	 (-1 * Ts_rank(decay_linear(correlation(IndNeutralize(((vwap * 0.728317) + (vwap *(1 - 0.728317))), IndClass.industry), volume, 4.25197), 16.2289), 8.19648))
     
    
    # Alpha#60	 (0 - (1 * ((2 * scale(rank(((((close - low) - (high - close)) / (high - low)) * volume)))) -scale(rank(ts_argmax(close, 10))))))
    def alpha_n60(self):
        divisor = (self.high - self.low).replace(0, 0.0001)
        inner = ((self.close - self.low) - (self.high - self.close)) * self.volume / divisor
        return - ((2 * scale(rank(inner))) - scale(rank(ts_argmax(self.close, 10))))
    
	# Alpha#61	 (rank((vwap - ts_min(vwap, 16.1219))) < rank(correlation(vwap, adv180, 17.9282)))
    def alpha_n61(self):
        adv180 = Mean(self.volume, 180)
        return (rank((self.vwap - ts_min(self.vwap, 16))) < rank(correlation(self.vwap, adv180, 18)))
    
	# Alpha#62	 ((rank(correlation(vwap, ts_sum(adv20, 22.4101), 9.91009)) < rank(((rank(open) +rank(open)) < (rank(((high + low) / 2)) + rank(high))))) * -1)
    def alpha_n62(self):
        adv20 = Mean(self.volume, 20)
        return ((rank(correlation(self.vwap, Mean(adv20, 22), 10)) < rank(((rank(self.open) +rank(self.open)) < (rank(((self.high + self.low) / 2)) + rank(self.high))))) * -1)
    
    # Alpha#63	 ((rank(decay_linear(delta(IndNeutralize(close, IndClass.industry), 2.25164), 8.22237))- rank(decay_linear(correlation(((vwap * 0.318108) + (open * (1 - 0.318108))), ts_sum(adv180,37.2467), 13.557), 12.2883))) * -1)
     
    
    # Alpha#64	 ((rank(correlation(ts_sum(((open * 0.178404) + (low * (1 - 0.178404))), 12.7054),ts_sum(adv120, 12.7054), 16.6208)) < rank(delta(((((high + low) / 2) * 0.178404) + (vwap * (1 -0.178404))), 3.69741))) * -1)
    def alpha_n64(self):
        adv120 = Mean(self.volume, 120)
        return ((rank(correlation(Mean(((self.open * 0.178404) + (self.low * (1 - 0.178404))), 13),Mean(adv120, 13), 17)) < rank(delta(((((self.high + self.low) / 2) * 0.178404) + (self.vwap * (1 -0.178404))), 4))) * -1)
    
    # Alpha#65	 ((rank(correlation(((open * 0.00817205) + (vwap * (1 - 0.00817205))), ts_sum(adv60,8.6911), 6.40374)) < rank((open - ts_min(open, 13.635)))) * -1)
    def alpha_n65(self):
        adv60 = Mean(self.volume, 60)
        return ((rank(correlation(((self.open * 0.00817205) + (self.vwap * (1 - 0.00817205))), Mean(adv60,9), 6)) < rank((self.open - ts_min(self.open, 14)))) * -1)
      
    # Alpha#66	 ((rank(decay_linear(delta(vwap, 3.51013), 7.23052)) + Ts_rank(decay_linear(((((low* 0.96633) + (low * (1 - 0.96633))) - vwap) / (open - ((high + low) / 2))), 11.4157), 6.72611)) * -1)
    def alpha_n66(self):
        return ((rank(decay_linear(delta(self.vwap, 4), 7)) + ts_rank(decay_linear(((((self.low* 0.96633) + (self.low * (1 - 0.96633))) - self.vwap) / (self.open - ((self.high + self.low) / 2))), 11), 7)) * -1)
    
    # Alpha#67	 ((rank((high - ts_min(high, 2.14593)))^rank(correlation(IndNeutralize(vwap,IndClass.sector), IndNeutralize(adv20, IndClass.subindustry), 6.02936))) * -1)
     
    
    # Alpha#68	 ((Ts_rank(correlation(rank(high), rank(adv15), 8.91644), 13.9333) <rank(delta(((close * 0.518371) + (low * (1 - 0.518371))), 1.06157))) * -1)
    def alpha_n68(self):
        adv15 = Mean(self.volume, 15)
        return ((ts_rank(correlation(rank(self.high), rank(adv15), 9), 14) <rank(delta(((self.close * 0.518371) + (self.low * (1 - 0.518371))), 1))) * -1)
    
    # Alpha#69	 ((rank(ts_max(delta(IndNeutralize(vwap, IndClass.industry), 2.72412),4.79344))^Ts_rank(correlation(((close * 0.490655) + (vwap * (1 - 0.490655))), adv20, 4.92416),9.0615)) * -1)
         
    # Alpha#70	 ((rank(delta(vwap, 1.29456))^Ts_rank(correlation(IndNeutralize(close,IndClass.industry), adv50, 17.8256), 17.9171)) * -1)
     
    
    # Alpha#71	 max(Ts_rank(decay_linear(correlation(Ts_rank(close, 3.43976), Ts_rank(adv180,12.0647), 18.0175), 4.20501), 15.6948), Ts_rank(decay_linear((rank(((low + open) - (vwap +vwap)))^2), 16.4662), 4.4388))
    def alpha_n71(self):
        adv180 = Mean(self.volume, 180)
        p1=ts_rank(decay_linear(correlation(ts_rank(self.close, 3), ts_rank(adv180,12), 18), 4), 16)
        p2=ts_rank(decay_linear((rank(((self.low + self.open) - (self.vwap +self.vwap))).pow(2)), 16), 4)   
        return Max2(p1,p2)
        #return max(ts_rank(decay_linear(correlation(ts_rank(self.close, 3), ts_rank(adv180,12), 18), 4), 16), ts_rank(decay_linear((rank(((self.low + self.open) - (self.vwap +self.vwap))).pow(2)), 16), 4))
    
    # Alpha#72	 (rank(decay_linear(correlation(((high + low) / 2), adv40, 8.93345), 10.1519)) /rank(decay_linear(correlation(Ts_rank(vwap, 3.72469), Ts_rank(volume, 18.5188), 6.86671),2.95011)))
    def alpha_n72(self):
        adv40 = Mean(self.volume, 40)
        return (rank(decay_linear(correlation(((self.high + self.low) / 2), adv40, 9), 10)) /rank(decay_linear(correlation(ts_rank(self.vwap, 4), ts_rank(self.volume, 19), 7),3)))
    
    # Alpha#73	 (max(rank(decay_linear(delta(vwap, 4.72775), 2.91864)),Ts_rank(decay_linear(((delta(((open * 0.147155) + (low * (1 - 0.147155))), 2.03608) / ((open *0.147155) + (low * (1 - 0.147155)))) * -1), 3.33829), 16.7411)) * -1)
    def alpha_n73(self):
        p1=rank(decay_linear(delta(self.vwap, 5), 3))
        p2=ts_rank(decay_linear(((delta(((self.open * 0.147155) + (self.low * (1 - 0.147155))), 2) / ((self.open *0.147155) + (self.low * (1 - 0.147155)))) * -1), 3), 17)
        return -1*np.maximum(p1, p2)
        #return (max(rank(decay_linear(delta(self.vwap, 5), 3)),ts_rank(decay_linear(((delta(((self.open * 0.147155) + (self.low * (1 - 0.147155))), 2) / ((self.open *0.147155) + (self.low * (1 - 0.147155)))) * -1), 3), 17)) * -1)
    
    # Alpha#74	 ((rank(correlation(close, ts_sum(adv30, 37.4843), 15.1365)) <rank(correlation(rank(((high * 0.0261661) + (vwap * (1 - 0.0261661)))), rank(volume), 11.4791)))* -1)
    def alpha_n74(self):
        adv30 = Mean(self.volume, 30)
        return ((rank(correlation(self.close, Mean(adv30, 37), 15)) <rank(correlation(rank(((self.high * 0.0261661) + (self.vwap * (1 - 0.0261661)))), rank(self.volume), 11)))* -1)
    
    # Alpha#75	 (rank(correlation(vwap, volume, 4.24304)) < rank(correlation(rank(low), rank(adv50),12.4413)))
    def alpha_n75(self):
        adv50 = Mean(self.volume, 50)
        return (rank(correlation(self.vwap, self.volume, 4)) < rank(correlation(rank(self.low), rank(adv50),12)))
    
    # Alpha#76	 (max(rank(decay_linear(delta(vwap, 1.24383), 11.8259)),Ts_rank(decay_linear(Ts_rank(correlation(IndNeutralize(low, IndClass.sector), adv81,8.14941), 19.569), 17.1543), 19.383)) * -1)
     

    # Alpha#77	 min(rank(decay_linear(((((high + low) / 2) + high) - (vwap + high)), 20.0451)),rank(decay_linear(correlation(((high + low) / 2), adv40, 3.1614), 5.64125)))
    def alpha_n77(self):
        adv40 = Mean(self.volume, 40)
        p1=rank(decay_linear(((((self.high + self.low) / 2) + self.high) - (self.vwap + self.high)), 20))
        p2=rank(decay_linear(correlation(((self.high + self.low) / 2), adv40, 3), 6))
        return np.minimum(p1, p2)
        #return min(rank(decay_linear(((((self.high + self.low) / 2) + self.high) - (self.vwap + self.high)), 20)),rank(decay_linear(correlation(((self.high + self.low) / 2), adv40, 3), 6)))
    
    # Alpha#78	 (rank(correlation(ts_sum(((low * 0.352233) + (vwap * (1 - 0.352233))), 19.7428),ts_sum(adv40, 19.7428), 6.83313))^rank(correlation(rank(vwap), rank(volume), 5.77492)))
    def alpha_n78(self):
        adv40 = Mean(self.volume, 40)
        return (rank(correlation(ts_sum(((self.low * 0.352233) + (self.vwap * (1 - 0.352233))), 20),ts_sum(adv40,20), 7)).pow(rank(correlation(rank(self.vwap), rank(self.volume), 6))))
    
    # Alpha#79	 (rank(delta(IndNeutralize(((close * 0.60733) + (open * (1 - 0.60733))),IndClass.sector), 1.23438)) < rank(correlation(Ts_rank(vwap, 3.60973), Ts_rank(adv150,9.18637), 14.6644)))
     
    # Alpha#80	 ((rank(sign(delta(IndNeutralize(((open * 0.868128) + (high * (1 - 0.868128))),IndClass.industry), 4.04545)))^Ts_rank(correlation(high, adv10, 5.11456), 5.53756)) * -1)
     
   
    # Alpha#81	 ((rank(log(product(rank((rank(correlation(vwap, ts_sum(adv10, 49.6054),8.47743))^4)), 14.9655))) < rank(correlation(rank(vwap), rank(volume), 5.07914))) * -1)
    def alpha_n81(self):
        adv10 = Mean(self.volume, 10)
        return ((rank(log(product(rank((rank(correlation(self.vwap, ts_sum(adv10, 50),8)).pow(4))), 15))) < rank(correlation(rank(self.vwap), rank(self.volume), 5))) * -1)
    
    # Alpha#82	 (min(rank(decay_linear(delta(open, 1.46063), 14.8717)),Ts_rank(decay_linear(correlation(IndNeutralize(volume, IndClass.sector), ((open * 0.634196) +(open * (1 - 0.634196))), 17.4842), 6.92131), 13.4283)) * -1)
     
    
    # Alpha#83	 ((rank(delay(((high - low) / (ts_sum(close, 5) / 5)), 2)) * rank(rank(volume))) / (((high -low) / (ts_sum(close, 5) / 5)) / (vwap - close)))
    def alpha_n83(self):
        return ((rank(delay(((self.high - self.low) / (ts_sum(self.close, 5) / 5)), 2)) * rank(rank(self.volume))) / (((self.high -self.low) / (ts_sum(self.close, 5) / 5)) / (self.vwap - self.close)))
    
    # Alpha#84	 SignedPower(Ts_rank((vwap - ts_max(vwap, 15.3217)), 20.7127), delta(close,4.96796))
    def alpha_n84(self):
        return pow(ts_rank((self.vwap - ts_max(self.vwap, 15)), 21), delta(self.close,5))
    
    # Alpha#85	 (rank(correlation(((high * 0.876703) + (close * (1 - 0.876703))), adv30,9.61331))^rank(correlation(Ts_rank(((high + low) / 2), 3.70596), Ts_rank(volume, 10.1595),7.11408)))
    def alpha_n85(self):
        adv30 = Mean(self.volume, 30)
        return (rank(correlation(((self.high * 0.876703) + (self.close * (1 - 0.876703))), adv30,10)).pow(rank(correlation(ts_rank(((self.high + self.low) / 2), 4), ts_rank(self.volume, 10),7))))
    
    # Alpha#86	 ((Ts_rank(correlation(close, ts_sum(adv20, 14.7444), 6.00049), 20.4195) < rank(((open+ close) - (vwap + open)))) * -1)

    def alpha_n86(self):
        adv20 = Mean(self.volume, 20)
        return ((ts_rank(correlation(self.close, Mean(adv20, 15), 6), 20) < rank(((self.open+ self.close) - (self.vwap +self.open)))) * -1)
    
    # Alpha#87	 (max(rank(decay_linear(delta(((close * 0.369701) + (vwap * (1 - 0.369701))),1.91233), 2.65461)), Ts_rank(decay_linear(abs(correlation(IndNeutralize(adv81,IndClass.industry), close, 13.4132)), 4.89768), 14.4535)) * -1)
     
    
    # Alpha#88	 min(rank(decay_linear(((rank(open) + rank(low)) - (rank(high) + rank(close))),8.06882)), Ts_rank(decay_linear(correlation(Ts_rank(close, 8.44728), Ts_rank(adv60,20.6966), 8.01266), 6.65053), 2.61957))
    def alpha_n88(self):
        adv60 = Mean(self.volume, 60)
        p1=rank(decay_linear(((rank(self.open) + rank(self.low)) - (rank(self.high) + rank(self.close))),8))
        p2=ts_rank(decay_linear(correlation(ts_rank(self.close, 8), ts_rank(adv60,21), 8), 7), 3)
        return np.minimum(p1,p2)
        #return min(rank(decay_linear(((rank(self.open) + rank(self.low)) - (rank(self.high) + rank(self.close))),8)), ts_rank(decay_linear(correlation(ts_rank(self.close, 8), ts_rank(adv60,20.6966), 8), 7), 3))
    
    # Alpha#89	 (Ts_rank(decay_linear(correlation(((low * 0.967285) + (low * (1 - 0.967285))), adv10,6.94279), 5.51607), 3.79744) - Ts_rank(decay_linear(delta(IndNeutralize(vwap,IndClass.industry), 3.48158), 10.1466), 15.3012))
     
    # Alpha#90	 ((rank((close - ts_max(close, 4.66719)))^Ts_rank(correlation(IndNeutralize(adv40,IndClass.subindustry), low, 5.38375), 3.21856)) * -1)
     
    # Alpha#91	 ((Ts_rank(decay_linear(decay_linear(correlation(IndNeutralize(close,IndClass.industry), volume, 9.74928), 16.398), 3.83219), 4.8667) -rank(decay_linear(correlation(vwap, adv30, 4.01303), 2.6809))) * -1)
     

    # Alpha#92	 min(Ts_rank(decay_linear(((((high + low) / 2) + close) < (low + open)), 14.7221),18.8683), Ts_rank(decay_linear(correlation(rank(low), rank(adv30), 7.58555), 6.94024),6.80584))
    def alpha_n92(self):
        adv30 = Mean(self.volume, 30)
        p1=ts_rank(decay_linear(((((self.high + self.low) / 2) + self.close) < (self.low + self.open)), 15),19)
        p2=ts_rank(decay_linear(correlation(rank(self.low), rank(adv30), 8), 7),7)
        return np.minimum(p1,p2)
        #return  min(ts_rank(decay_linear(((((self.high + self.low) / 2) + self.close) < (self.low + self.open)), 15),19), ts_rank(decay_linear(correlation(rank(self.low), rank(adv30), 8), 7),7))
    
    # Alpha#93	 (Ts_rank(decay_linear(correlation(IndNeutralize(vwap, IndClass.industry), adv81,17.4193), 19.848), 7.54455) / rank(decay_linear(delta(((close * 0.524434) + (vwap * (1 -0.524434))), 2.77377), 16.2664)))
     
    
    # Alpha#94	 ((rank((vwap - ts_min(vwap, 11.5783)))^Ts_rank(correlation(Ts_rank(vwap,19.6462), Ts_rank(adv60, 4.02992), 18.0926), 2.70756)) * -1)
    def alpha_n94(self):
        adv60 = Mean(self.volume, 60)
        return ((rank((self.vwap - ts_min(self.vwap, 12))).pow(ts_rank(correlation(ts_rank(self.vwap,20), ts_rank(adv60, 4), 18), 3)) * -1))
    
    # Alpha#95	 (rank((open - ts_min(open, 12.4105))) < Ts_rank((rank(correlation(ts_sum(((high + low)/ 2), 19.1351), ts_sum(adv40, 19.1351), 12.8742))^5), 11.7584))
    def alpha_n95(self):
        adv40 = Mean(self.volume, 40)
        return (rank((self.open - ts_min(self.open, 12))) < ts_rank((rank(correlation(Mean(((self.high + self.low)/ 2), 19), Mean(adv40, 19), 13)).pow(5)), 12))
    
    # Alpha#96	 (max(Ts_rank(decay_linear(correlation(rank(vwap), rank(volume), 3.83878),4.16783), 8.38151), Ts_rank(decay_linear(Ts_ArgMax(correlation(Ts_rank(close, 7.45404),Ts_rank(adv60, 4.13242), 3.65459), 12.6556), 14.0365), 13.4143)) * -1)
    def alpha_n96(self):
        adv60 = Mean(self.volume, 60)
        p1=ts_rank(decay_linear(correlation(rank(self.vwap), rank(self.volume), 4),4), 8)
        p2=ts_rank(decay_linear(ts_argmax(correlation(ts_rank(self.close, 7),ts_rank(adv60, 4), 4), 13), 14), 13)
        return -np.maximum(p1,p2)
        #return (max(ts_rank(decay_linear(correlation(rank(self.vwap), rank(self.volume), 4),4), 8), ts_rank(decay_linear(ts_argmax(correlation(ts_rank(self.close, 7),ts_rank(adv60, 4), 4), 13), 14), 13)) * -1)
    
    # Alpha#97	 ((rank(decay_linear(delta(IndNeutralize(((low * 0.721001) + (vwap * (1 - 0.721001))),IndClass.industry), 3.3705), 20.4523)) - Ts_rank(decay_linear(Ts_rank(correlation(Ts_rank(low,7.87871), Ts_rank(adv60, 17.255), 4.97547), 18.5925), 15.7152), 6.71659)) * -1)
     
    
    # Alpha#98	 (rank(decay_linear(correlation(vwap, ts_sum(adv5, 26.4719), 4.58418), 7.18088)) -rank(decay_linear(Ts_rank(Ts_ArgMin(correlation(rank(open), rank(adv15), 20.8187), 8.62571),6.95668), 8.07206)))
    def alpha_n98(self):
        adv5 = Mean(self.volume, 5)
        adv15 = Mean(self.volume, 15)
        return (rank(decay_linear(correlation(self.vwap, Mean(adv5, 26), 5), 7)) -rank(decay_linear(ts_rank(ts_argmin(correlation(rank(self.open), rank(adv15), 21), 9),7), 8)))
    
    # Alpha#99	 ((rank(correlation(ts_sum(((high + low) / 2), 19.8975), ts_sum(adv60, 19.8975), 8.8136)) <rank(correlation(low, volume, 6.28259))) * -1)
    def alpha_n99(self):
        adv60 = Mean(self.volume, 60)
        return ((rank(correlation(ts_sum(((self.high + self.low) / 2), 20), ts_sum(adv60, 20), 9)) <rank(correlation(self.low, self.volume, 6))) * -1)
    
    # Alpha#100	 (0 - (1 * (((1.5 * scale(indneutralize(indneutralize(rank(((((close - low) - (high -close)) / (high - low)) * volume)), IndClass.subindustry), IndClass.subindustry))) -scale(indneutralize((correlation(close, rank(adv20), 5) - rank(ts_argmin(close, 30))),IndClass.subindustry))) * (volume / adv20))))
     

    # Alpha#101	 ((close - open) / ((high - low) + .001))
    def alpha_n101(self):
        return (self.close - self.open) /((self.high - self.low) + 0.001)

        # Alpha#2	 (-1 * correlation(rank(delta(log(volume), 2)), rank(((close - open) / open)), 6))
    def alpha_n102(self):
        df = -1 * correlation(rank(delta(log(self.volume), 2)), rank((self.close - self.open) / self.open), 6)
        return df.replace([-np.inf, np.inf], 0).fillna(value=0)
    
    # Alpha#3	 (-1 * correlation(rank(open), rank(volume), 10))
    def alpha_n103(self):
        df = -1 * correlation(rank(self.open), rank(self.volume), 10)
        return df.replace([-np.inf, np.inf], 0).fillna(value=0)
    
    # Alpha#4	 (-1 * Ts_rank(rank(low), 9))
    def alpha_n104(self):
        return -1 * ts_rank(rank(self.low), 9)
    
    # Alpha#5	 (rank((open - (ts_sum(vwap, 10) / 10))) * (-1 * abs(rank((close - vwap)))))
    def alpha_n105(self):
        return  (rank((self.open - (ts_sum(self.vwap, 10) / 10))) * (-1 * abs(rank((self.close - self.vwap)))))
    
    # Alpha#6	 (-1 * correlation(open, volume, 10))
    def alpha_n106(self):
        df = -1 * correlation(self.open, self.volume, 10)
        return df.replace([-np.inf, np.inf], 0).fillna(value=0)
    
    # Alpha#7	 ((adv20 < volume) ? ((-1 * ts_rank(abs(delta(close, 7)), 60)) * sign(delta(close, 7))) : (-1* 1))
    def alpha_n107(self):
        adv20 = Mean(self.volume, 20)
        alpha = -1 * ts_rank(abs(delta(self.close, 7)), 60) * sign(delta(self.close, 7))
        alpha[adv20 >= self.volume] = -1
        return alpha
    
    # Alpha#8	 (-1 * rank(((ts_sum(open, 5) * ts_sum(returns, 5)) - delay((ts_sum(open, 5) * ts_sum(returns, 5)),10))))
    def alpha_n108(self):
        return -1 * (rank(((ts_sum(self.open, 5) * ts_sum(self.returns, 5)) -
                           delay((ts_sum(self.open, 5) * ts_sum(self.returns, 5)), 10))))
    
    # Alpha#9	 ((0 < ts_min(delta(close, 1), 5)) ? delta(close, 1) : ((ts_max(delta(close, 1), 5) < 0) ?delta(close, 1) : (-1 * delta(close, 1))))
    def alpha_n109(self):
        delta_close = delta(self.close, 1)
        cond_1 = ts_min(delta_close, 5) > 0
        cond_2 = ts_max(delta_close, 5) < 0
        alpha = -1 * delta_close
        alpha[cond_1 | cond_2] = delta_close
        return alpha
    
    # Alpha#10	 rank(((0 < ts_min(delta(close, 1), 4)) ? delta(close, 1) : ((ts_max(delta(close, 1), 4) < 0)? delta(close, 1) : (-1 * delta(close, 1)))))
    def alpha_n110(self):
        delta_close = delta(self.close, 1)
        cond_1 = ts_min(delta_close, 4) > 0
        cond_2 = ts_max(delta_close, 4) < 0
        alpha = -1 * delta_close
        alpha[cond_1 | cond_2] = delta_close
        return alpha
    
    # Alpha#11	 ((rank(ts_max((vwap - close), 3)) + rank(ts_min((vwap - close), 3))) *rank(delta(volume, 3)))
    def alpha_n111(self):
        return ((rank(ts_max((self.vwap - self.close), 3)) + rank(ts_min((self.vwap - self.close), 3))) *rank(delta(self.volume, 3)))
    
    # Alpha#12	 (sign(delta(volume, 1)) * (-1 * delta(close, 1)))
    def alpha_n112(self):
        return sign(delta(self.volume, 1)) * (-1 * delta(self.close, 1))

    # Alpha#13	 (-1 * rank(covariance(rank(close), rank(volume), 5)))
    def alpha_n113(self):
        return -1 * rank(covariance(rank(self.close), rank(self.volume), 5))
    
    # Alpha#14	 ((-1 * rank(delta(returns, 3))) * correlation(open, volume, 10))
    def alpha_n114(self):
        df = correlation(self.open, self.volume, 10)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return -1 * rank(delta(self.returns, 3)) * df
    
    # Alpha#15	 (-1 * ts_sum(rank(correlation(rank(high), rank(volume), 3)), 3))
    def alpha_n115(self):
        df = correlation(rank(self.high), rank(self.volume), 3)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return -1 * ts_sum(rank(df), 3)
    
    # Alpha#16	 (-1 * rank(covariance(rank(high), rank(volume), 5)))
    def alpha_n116(self):
        return -1 * rank(covariance(rank(self.high), rank(self.volume), 5))
    
    # Alpha#17	 (((-1 * rank(ts_rank(close, 10))) * rank(delta(delta(close, 1), 1))) *rank(ts_rank((volume / adv20), 5)))
    def alpha_n117(self):
        adv20 = Mean(self.volume, 20)
        return -1 * (rank(ts_rank(self.close, 10)) *
                     rank(delta(delta(self.close, 1), 1)) *
                     rank(ts_rank((self.volume / adv20), 5)))
        
    # Alpha#18	 (-1 * rank(((stddev(abs((close - open)), 5) + (close - open)) + correlation(close, open,10))))
    def alpha_n118(self):
        df = correlation(self.close, self.open, 10)
        df = df.replace([-np.inf, np.inf], 0).fillna(value=0)
        return -1 * (rank((stddev(abs((self.close - self.open)), 5) + (self.close - self.open)) +
                          df))
    
    # Alpha#19	 ((-1 * sign(((close - delay(close, 7)) + delta(close, 7)))) * (1 + rank((1 + ts_sum(returns,250)))))
    def alpha_n119(self):
        return ((-1 * sign((self.close - delay(self.close, 7)) + delta(self.close, 7))) *
                (1 + rank(1 + ts_sum(self.returns, 250))))

    def alpha_n120(self):  
        ####COUNT(CLOSE>OPEN & BANCHMARKINDEXCLOSE
        cond1 = ((self.close>self.open)&(self.benchmark_close<self.benchmark_open))
        cond2 = (self.benchmark_close<self.benchmark_open)
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = 1
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[cond2] = 1     
        return Count(part1,50)/Count(part2,50)

    def alpha_n121(self):  
        ####COUNT((CLOSE>OPEN & BANCHMARKINDEXCLOSE>BANCHMARKINDEXOPEN)OR(CLOSE
        cond1 = ((self.close>self.open) & (self.benchmark_close>self.benchmark_open))
        cond2 = ((self.close<self.open) & (self.benchmark_close<self.benchmark_open))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = 1
        part[cond2] = 1
        return Count(part,20)/20

    def alpha_1(self): #平均1751个数据
        ##### (-1 * correlation(rank(delta(log(VOLUME), 1)), rank(((CLOSE - OPEN) / OPEN)), 6))#### 
        return (-1 * correlation(rank(delta(log(self.volume), 1)), rank(((self.close - self.open) / self.open)), 6))
    
    def alpha_2(self): #1783
        ##### -1 * delta((((close-low)-(high-close))/(high-low)),1))####
        return -1*delta((((self.close-self.low)-(self.high-self.close))/(self.high-self.low)),1) 
    
    def alpha_3(self): 
        ##### ts_sum((CLOSE=delay(CLOSE,1)?0:CLOSE-(CLOSE>delay(CLOSE,1)?MIN(LOW,delay(CLOSE,1)):MAX(HIGH,delay(CLOSE,1)))),6) ####
        cond1 = (self.close == delay(self.close,1))
        cond2 = (self.close > delay(self.close,1))
        cond3 = (self.close < delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index=self.close.index)
        part[cond1] = 0
        part[cond2] = self.close - Min2(self.low,delay(self.close,1))
        part[cond3] = self.close - Max2(self.high,delay(self.close,1))
        return ts_sum(part, 6)
    
    def alpha_4(self):  
        #####((((ts_sum(CLOSE, 8) / 8) + stddev(CLOSE, 8)) < (ts_sum(CLOSE, 2) / 2)) ? (-1 * 1) : (((ts_sum(CLOSE, 2) / 2) <((ts_sum(CLOSE, 8) / 8) - stddev(CLOSE, 8))) ? 1 : (((1 < (VOLUME / MEAN(VOLUME,20))) || ((VOLUME /MEAN(VOLUME,20)) == 1)) ? 1 : (-1 * 1))))
        cond1 = ((ts_sum(self.close, 8)/8 + stddev(self.close, 8)) < ts_sum(self.close, 2)/2)
        cond2 = ((ts_sum(self.close, 8)/8 + stddev(self.close, 8)) > ts_sum(self.close, 2)/2)
        cond3 = ((ts_sum(self.close, 8)/8 + stddev(self.close, 8)) == ts_sum(self.close, 2)/2)
        cond4 = (self.volume/Mean(self.volume, 20) >= 1)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index=self.close.index)
        part[cond1] = -1
        part[cond2] = 1
        part[cond3][cond4] = 1
        part[cond3][~cond4] = -1
        
        return part
    
    def alpha_5(self): #1447
        ####(-1 * ts_max(correlation(ts_rank(VOLUME, 5), ts_rank(HIGH, 5), 5), 3))###
        return -1*ts_max(correlation(ts_rank(self.volume, 5),ts_rank(self.high, 5),5), 3)
    
    def alpha_6(self): #1779
        ####(rank(sign(delta((((OPEN * 0.85) + (HIGH * 0.15))), 4)))* -1)### 
        return -1*rank(sign(delta(((self.open * 0.85) + (self.high * 0.15)), 4)))
    
    def alpha_7(self): #1782
        ####((rank(MAX((VWAP - CLOSE), 3)) + rank(MIN((VWAP - CLOSE), 3))) * rank(delta(VOLUME, 3)))###
        return ((rank(Max((self.vwap - self.close), 3)) + rank(Min((self.vwap - self.close), 3))) * rank(delta(self.volume, 3)))
    
    def alpha_8(self): #1779
        ####rank(delta(((((HIGH + LOW) / 2) * 0.2) + (VWAP * 0.8)), 4) * -1)###    
        return rank(delta(((((self.high + self.low) / 2) * 0.2) + (self.vwap * 0.8)), 4) * -1)
    
    def alpha_9(self): #1790
        ####ewma(((HIGH+LOW)/2-(delay(HIGH,1)+delay(LOW,1))/2)*(HIGH-LOW)/VOLUME,7,2)###  
        return ewma(((self.high+self.low)/2-(delay(self.high,1)+delay(self.low,1))/2)*(self.high-self.low)/self.volume,7,2)
    
    def alpha_10(self):    
        ####(rank(MAX(((RET < 0) ? stddev(RET, 20) : CLOSE)^2),5))###
        cond = (self.returns < 0)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.returns.index)
        part[cond] = stddev(self.returns, 20)
        part[~cond] = self.close
        part = part**2
        
        return rank(Max(part, 5))
    
    def alpha_11(self): #1782
        ####ts_sum(((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW)*VOLUME,6)###   
        return ts_sum(((self.close-self.low)-(self.high-self.close))/(self.high-self.low)*self.volume,6)
    
    def alpha_12(self): #1779
        ####(rank((OPEN - (ts_sum(VWAP, 10) / 10)))) * (-1 * (rank(abs((CLOSE - VWAP)))))###   
        return (rank((self.open - (ts_sum(self.vwap, 10) / 10)))) * (-1 * (rank(abs((self.close - self.vwap)))))
    
    def alpha_13(self): #1790
        ####(((HIGH * LOW)^0.5) - VWAP)###
        return (((self.high * self.low)**0.5) - self.vwap)
    
    def alpha_14(self): #1776
        ####CLOSE-delay(CLOSE,5)###
        return self.close-delay(self.close,5)
    
    def alpha_15(self): #1790
        ####OPEN/delay(CLOSE,1)-1###
        return self.open/delay(self.close,1)-1
    
    def alpha_16(self): #1736   
        ####(-1 * ts_max(rank(correlation(rank(VOLUME), rank(VWAP), 5)), 5))###
        return (-1 * ts_max(rank(correlation(rank(self.volume), rank(self.vwap), 5)), 5))
        
    def alpha_17(self): #1776   
        ####rank((VWAP - MAX(VWAP, 15)))^delta(CLOSE, 5)###
        return rank((self.vwap - Max(self.vwap, 15)))**delta(self.close, 5)
    
    def alpha_18(self): #1776   
        ####CLOSE/delay(CLOSE,5)###
        return self.close/delay(self.close,5)  
    
    def alpha_19(self):  
        ####(CLOSE
        cond1 = (self.close < delay(self.close,5))
        cond2 = (self.close == delay(self.close,5))
        cond3 = (self.close > delay(self.close,5))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = (self.close-delay(self.close,5))/delay(self.close,5)
        part[cond2] = 0
        part[cond3] = (self.close-delay(self.close,5))/self.close
        
        return part
       
    def alpha_20(self): #1773      
        ####(CLOSE-delay(CLOSE,6))/delay(CLOSE,6)*100###
        return (self.close-delay(self.close,6))/delay(self.close,6)*100
    
    # def alpha_21(self):  #reg？
    #     ####REGBETA(MEAN(CLOSE,6),SEQUENCE(6))###
    #     return 0
    
    def alpha_22(self): #1736  
        ####ewma(((CLOSE-MEAN(CLOSE,6))/MEAN(CLOSE,6)-delay((CLOSE-MEAN(CLOSE,6))/MEAN(CLOSE,6),3)),12,1)###
        return ewma(((self.close-Mean(self.close,6))/Mean(self.close,6)-delay((self.close-Mean(self.close,6))/Mean(self.close,6),3)),12,1)
     
    def alpha_23(self):  
        ####ewma((CLOSE>delay(CLOSE,1)?stddev(CLOSE,20):0),20,1) / (ewma((CLOSE>delay(CLOSE,1)?stddev(CLOSE,20):0),20,1) + ewma((CLOSE<=delay(CLOSE,1)?stddev(CLOSE,20):0),20,1))*100###
        cond = (self.close > delay(self.close,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns,index =self.close.index)
        part1[cond] = stddev(self.close,20)
        part1[~cond] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = stddev(self.close,20)
        part2[cond] = 0
        
        return 100*ewma(part1,20,1)/(ewma(part1,20,1) + ewma(part2,20,1))
        
    def alpha_24(self): #1776  
        ####ewma(CLOSE-delay(CLOSE,5),5,1)###
        return ewma(self.close-delay(self.close,5),5,1)
    
    def alpha_25(self):  #886  数据量较少
        ####((-1 * rank((delta(CLOSE, 7) * (1 - rank(decay_linear((VOLUME / MEAN(VOLUME,20)), 9)))))) * (1 + rank(ts_sum(RET, 250))))###
        return ((-1 * rank((delta(self.close, 7) * (1 - rank(decay_linear((self.volume / Mean(self.volume,20)), 9)))))) * (1 + rank(ts_sum(self.returns, 250))))
    
    def alpha_26(self):   #平均数据量914，获得的数据量较少 
        ####((((ts_sum(CLOSE, 7) / 7) - CLOSE)) + ((correlation(VWAP, delay(CLOSE, 5), 230))))###
        return ((((ts_sum(self.close, 7) / 7) - self.close)) + ((correlation(self.vwap, delay(self.close, 5), 230))))
    
    def alpha_27(self):  
        ####WMA((CLOSE-delay(CLOSE,3))/delay(CLOSE,3)*100+(CLOSE-delay(CLOSE,6))/delay(CLOSE,6)*100,12)###
        A = (self.close-delay(self.close,3))/delay(self.close,3)*100+(self.close-delay(self.close,6))/delay(self.close,6)*100
        return Wma(A, 12)
    
    def alpha_28(self):   #1728 
        ####3*ewma((CLOSE-ts_min(LOW,9))/(ts_max(HIGH,9)-ts_min(LOW,9))*100,3,1)-2*ewma(ewma((CLOSE-ts_min(LOW,9))/(MAX(HIGH,9)-ts_max(LOW,9))*100,3,1),3,1)###
        return 3*ewma((self.close-ts_min(self.low,9))/(ts_max(self.high,9)-ts_min(self.low,9))*100,3,1)-2*ewma(ewma((self.close-ts_min(self.low,9))/(Max(self.high,9)-ts_max(self.low,9))*100,3,1),3,1)
    
    def alpha_29(self):   #1773 
        ####(CLOSE-delay(CLOSE,6))/delay(CLOSE,6)*VOLUME###
        return (self.close-delay(self.close,6))/delay(self.close,6)*self.volume
    
    # def alpha_30(self):  #reg？
    #     ####WMA((REGRESI(CLOSE/delay(CLOSE)-1,MKT,SMB,HML， 60))^2,20)###
    #     return 0
    
    def alpha_31(self):   #1714
        ####(CLOSE-MEAN(CLOSE,12))/MEAN(CLOSE,12)*100###
        return (self.close-Mean(self.close,12))/Mean(self.close,12)*100
    
    def alpha_32(self):   #1505
        ####(-1 * ts_sum(rank(correlation(rank(HIGH), rank(VOLUME), 3)), 3))###
        return (-1 * ts_sum(rank(correlation(rank(self.high), rank(self.volume), 3)), 3))
    
    def alpha_33(self):   #904  数据量较少
        ####((((-1 * ts_min(LOW, 5)) + delay(ts_min(LOW, 5), 5)) * rank(((ts_sum(RET, 240) - ts_sum(RET, 20)) / 220))) *ts_rank(VOLUME, 5))###
        return ((((-1 * ts_min(self.low, 5)) + delay(ts_min(self.low, 5), 5)) * rank(((ts_sum(self.returns, 240) - ts_sum(self.returns, 20)) / 220))) *ts_rank(self.volume, 5))
    
    def alpha_34(self):   #1714
        ####MEAN(CLOSE,12)/CLOSE###
        return Mean(self.close,12)/self.close
    
    def alpha_35(self):   #1790    (OPEN * 0.65) +(OPEN *0.35)有问题
        ####(MIN(rank(decay_linear(delta(OPEN, 1), 15)), rank(decay_linear(correlation((VOLUME), ((OPEN * 0.65) +(OPEN *0.35)), 17),7))) * -1)###
        return (Min2(rank(decay_linear(delta(self.open, 1), 15)), rank(decay_linear(correlation((self.volume), ((self.open * 0.65) +(self.open *0.35)), 17),7))) * -1)
     
    def alpha_36(self):   #1714
        ####rank(ts_sum(correlation(rank(VOLUME), rank(VWAP),6), 2))###
        return rank(ts_sum(correlation(rank(self.volume), rank(self.vwap),6 ), 2))
    
    def alpha_37(self):   #1713
        ####(-1 * rank(((ts_sum(OPEN, 5) * ts_sum(RET, 5)) - delay((ts_sum(OPEN, 5) * ts_sum(RET, 5)), 10))))###
        return (-1 * rank(((ts_sum(self.open, 5) * ts_sum(self.returns, 5)) - delay((ts_sum(self.open, 5) * ts_sum(self.returns, 5)), 10))))
    
    def alpha_38(self):  
        ####(((ts_sum(HIGH, 20) / 20) < HIGH) ? (-1 * delta(HIGH, 2)) : 0)
        cond = ((ts_sum(self.high, 20) / 20) < self.high)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1 * delta(self.high, 2)
        part[~cond] = 0
        
        return part
    
    def alpha_39(self):   #1666
        ####((rank(decay_linear(delta((CLOSE), 2),8)) - rank(decay_linear(correlation(((VWAP * 0.3) + (OPEN * 0.7)),ts_sum(MEAN(VOLUME,180), 37), 14), 12))) * -1)###
        return ((rank(decay_linear(delta((self.close), 2),8)) - rank(decay_linear(correlation(((self.vwap * 0.3) + (self.open * 0.7)),ts_sum(Mean(self.volume,180), 37), 14), 12))) * -1)
    
    def alpha_40(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:0),26)/ts_sum((CLOSE<=delay(CLOSE,1)?VOLUME:0),26)*100###
        cond = (self.close > delay(self.close,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = self.volume
        part1[~cond] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = self.volume
        part2[cond] = 0
        
        return ts_sum(part1,26)/ts_sum(part2,26)*100
    
    def alpha_41(self):   #1782
        ####(rank(MAX(delta((VWAP), 3), 5))* -1)###
        return (rank(Max(delta((self.vwap), 3), 5))* -1)
    
    def alpha_42(self):   #1399  数据量较少
        ####((-1 * rank(stddev(HIGH, 10))) * correlation(HIGH, VOLUME, 10))###
        return ((-1 * rank(stddev(self.high, 10))) * correlation(self.high, self.volume, 10))
    
    def alpha_43(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:(CLOSE
        cond1 = (self.close > delay(self.close,1))
        cond2 = (self.close < delay(self.close,1))
        cond3 = (self.close == delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = self.volume
        part[cond2] = -self.volume
        part[cond3] = 0
        
        return ts_sum(part,6)
    
    def alpha_44(self):   #1748
        ####(ts_rank(decay_linear(correlation(((LOW )), MEAN(VOLUME,10), 7), 6),4) + ts_rank(decay_linear(delta((VWAP),3), 10), 15))###
        return (ts_rank(decay_linear(correlation(((self.low)), Mean(self.volume,10), 7), 6),4) + ts_rank(decay_linear(delta((self.vwap),3), 10), 15))
    
    def alpha_45(self):   #1070  数据量较少
        ####(rank(delta((((CLOSE * 0.6) + (OPEN *0.4))), 1)) * rank(correlation(VWAP, MEAN(VOLUME,150), 15)))###
        return (rank(delta((((self.close * 0.6) + (self.open *0.4))), 1)) * rank(correlation(self.vwap, Mean(self.volume,150), 15)))
    
    def alpha_46(self):   #1630
        ####(MEAN(CLOSE,3)+MEAN(CLOSE,6)+MEAN(CLOSE,12)+MEAN(CLOSE,24))/(4*CLOSE)###
        return (Mean(self.close,3)+Mean(self.close,6)+Mean(self.close,12)+Mean(self.close,24))/(4*self.close)
    
    def alpha_47(self):   #1759
        ####ewma((ts_max(HIGH,6)-CLOSE)/(ts_max(HIGH,6)-ts_min(LOW,6))*100,9,1)###
        return ewma((ts_max(self.high,6)-self.close)/(ts_max(self.high,6)-ts_min(self.low,6))*100,9,1)
    
    def alpha_48(self):   #1657
        ####(-1*((rank(((sign((CLOSE - delay(CLOSE, 1))) + sign((delay(CLOSE, 1) - delay(CLOSE, 2)))) + sign((delay(CLOSE, 2) - delay(CLOSE, 3)))))) * ts_sum(VOLUME, 5)) / ts_sum(VOLUME, 20))###
        return (-1*((rank(((sign((self.close - delay(self.close, 1))) + sign((delay(self.close, 1) - delay(self.close, 2)))) + sign((delay(self.close, 2) - delay(self.close, 3)))))) * ts_sum(self.volume, 5)) / ts_sum(self.volume, 20))
    
    def alpha_49(self):  
        ####ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12) / (ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12) + ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))
        cond = ((self.high + self.low) > (delay(self.high,1) + delay(self.low,1)))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 0
        part1[~cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = 0
        part2[cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        
        return ts_sum(part1, 12) / (ts_sum(part1, 12) + ts_sum(part2, 12))
    
    def alpha_50(self):  
        ####ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)/(ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)+ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))-ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)/(ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)+ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))###
        cond = ((self.high + self.low) <= (delay(self.high,1) + delay(self.low,1)))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 0
        part1[~cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = 0
        part2[cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        
        return (ts_sum(part1, 12) - ts_sum(part2, 12)) / (ts_sum(part1, 12) + ts_sum(part2, 12)) 

    def alpha_51(self):  
        ####ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12) / (ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)+ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))###
        cond = ((self.high + self.low) <= (delay(self.high,1) + delay(self.low,1)))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 0
        part1[~cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = 0
        part2[cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        
        return ts_sum(part1, 12) / (ts_sum(part1, 12) + ts_sum(part2, 12))
    
    def alpha_52(self):   #1611
        ####ts_sum(MAX(0,HIGH-delay((HIGH+LOW+CLOSE)/3,1)),26)/ts_sum(MAX(0,delay((HIGH+LOW+CLOSE)/3,1)-L),26)*100###
        return ts_sum(Max(self.high-delay((self.high+self.low+self.close)/3,1),0),26)/ts_sum(Max(delay((self.high+self.low+self.close)/3,1)-self.low, 0),26)*100
    
    def alpha_53(self):  
        ####COUNT(CLOSE>delay(CLOSE,1),12)/12*100###
        cond = (self.close > delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1 #把满足条件的记为1，之后统计1的个数
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[0:12] = np.nan
        for i in range(12,len(part1)+1): 
            part1.iloc[i-1:i] = part.iloc[i-12:i].value_counts().get(1)
        
        return part1
    
    def alpha_54(self):   #1729
        ####(-1 * rank((stddev(abs(CLOSE - OPEN)) + (CLOSE - OPEN)) + correlation(CLOSE, OPEN,10)))###
        return (-1 * rank(((abs(self.close - self.open)).stddev() + (self.close - self.open)) + correlation(self.close, self.open,10)))
    
    def alpha_55(self):  #公式有问题
        ####ts_sum(16*(CLOSE-delay(CLOSE,1)+(CLOSE-OPEN)/2+delay(CLOSE,1)-delay(OPEN,1))/((abs(HIGH-delay(CLOSE,1))>abs(LOW-delay(CLOSE,1)) & abs(HIGH-delay(CLOSE,1))>abs(HIGH-delay(LOW,1))?abs(HIGH-delay(CLOSE,1))+abs(LOW-delay(CLOSE,1))/2 + abs(delay(CLOSE,1)-delay(OPEN,1))/4:(abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(LOW,1)) & abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(CLOSE,1))?abs(LOW-delay(CLOSE,1))+abs(HIGH-delay(CLOSE,1))/2+abs(delay(CLOSE,1)-delay(OPEN,1))/4:abs(HIGH-delay(LOW,1))+abs(delay(CLOSE,1)-delay(OPEN,1))/4)))*MAX(abs(HIGH-delay(CLOSE,1)),abs(LOW-delay(CLOSE,1))),20)
        A = abs(self.high - delay(self.close, 1))
        B = abs(self.low - delay(self.close, 1))
        C = abs(self.high - delay(self.low, 1))
        cond1 = ((A > B) & (A > C))
        cond2 = ((B > C) & (B > A))
        cond3 = ((C >= A) & (C >= B))
        part0 = 16*(self.close + (self.close - self.open)/2 - delay(self.open,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = abs(self.high - delay(self.close, 1)) + abs(self.low - delay(self.close, 1))/2 + abs(delay(self.close, 1)-delay(self.open, 1))/4
        part1[cond2] = abs(self.low - delay(self.close, 1)) + abs(self.high - delay(self.close, 1))/2 + abs(delay(self.close, 1)-delay(self.open, 1))/4
        part1[cond3] = abs(self.high - delay(self.low, 1)) + abs(delay(self.close, 1)-delay(self.open, 1))/4
        
        return ts_sum(part0/part1,20)
    
    def alpha_56(self):  
        ####(rank((OPEN - ts_min(OPEN, 12))) < rank((rank(correlation(ts_sum(((HIGH + LOW) / 2), 19),ts_sum(MEAN(VOLUME,40), 19), 13))^5)))###
        A = rank((self.open - ts_min(self.open, 12)))
        B = rank((rank(correlation(ts_sum(((self.high + self.low) / 2), 19),ts_sum(Mean(self.volume,40), 19), 13))**5))
        cond = (A < B)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1
        #part[~cond] = 0
        return part
    
    def alpha_57(self):   #1736
        ####ewma((CLOSE-ts_min(LOW,9))/(ts_max(HIGH,9)-ts_min(LOW,9))*100,3,1)###
        return ewma((self.close-ts_min(self.low,9))/(ts_max(self.high,9)-ts_min(self.low,9))*100,3,1)
    
    def alpha_58(self):  
        ####COUNT(CLOSE>delay(CLOSE,1),20)/20*100###

        cond = (self.close > delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1 #把满足条件的记为1，之后统计1的个数
        '''
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[0:19] = np.nan
        for i in range(20,len(part1)+1): 
            part1.iloc[i-1:i] = part.iloc[i-20:i].value_counts().get(1)
        return part1'''
        return Count(part,20)
        
    
    def alpha_59(self):  
        ####ts_sum((CLOSE=delay(CLOSE,1)?0:CLOSE-(CLOSE>delay(CLOSE,1)?MIN(LOW,delay(CLOSE,1)):MAX(HIGH,delay(CLOSE,1)))),20)###
        cond1 = (self.close == delay(self.close,1))
        cond2 = (self.close > delay(self.close,1))
        cond3 = (self.close < delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = 0
        part[cond2] = self.close - Min2(self.low,delay(self.close,1))
        part[cond3] = self.close - Max2(self.low,delay(self.close,1))
        
        return ts_sum(part, 20)
    
    def alpha_60(self):   #1635
        ####ts_sum(((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW)*VOLUME,20)###
        return ts_sum(((self.close-self.low)-(self.high-self.close))/(self.high-self.low)*self.volume,20)

    def alpha_61(self):   #1790
        ####(MAX(rank(decay_linear(delta(VWAP, 1), 12)),rank(decay_linear(rank(correlation((LOW),MEAN(VOLUME,80), 8)), 17))) * -1)###
        return (Max2(rank(decay_linear(delta(self.vwap, 1), 12)),rank(decay_linear(rank(correlation((self.low),Mean(self.volume,80), 8)), 17))) * -1)
    
    def alpha_62(self):   #1479
        ####(-1 * correlation(HIGH, rank(VOLUME), 5))###
        return (-1 * correlation(self.high, rank(self.volume), 5))
    
    def alpha_63(self):   #1789
        ####ewma(MAX(CLOSE-delay(CLOSE,1),0),6,1)/ewma(abs(CLOSE-delay(CLOSE,1)),6,1)*100###
        return ewma(Max(self.close-delay(self.close,1),0),6,1)/ewma(abs(self.close-delay(self.close,1)),6,1)*100
    
    def alpha_64(self):   #1774
        ####(MAX(rank(decay_linear(correlation(rank(VWAP), rank(VOLUME), 4), 4)),rank(decay_linear(MAX(correlation(rank(CLOSE), rank(MEAN(VOLUME,60)), 4), 13), 14))) * -1)###
        return (Max2(rank(decay_linear(correlation(rank(self.vwap), rank(self.volume), 4), 4)),rank(decay_linear(Max(correlation(rank(self.close), rank(Mean(self.volume,60)), 4), 13), 14))) * -1)
    
    def alpha_65(self):   #1759
        ####MEAN(CLOSE,6)/CLOSE###
        return Mean(self.close,6)/self.close
    
    def alpha_66(self):   #1759
        ####(CLOSE-MEAN(CLOSE,6))/MEAN(CLOSE,6)*100###
        return (self.close-Mean(self.close,6))/Mean(self.close,6)*100
    
    def alpha_67(self):   #1759
        ####ewma(MAX(CLOSE-delay(CLOSE,1),0),24,1)/ewma(abs(CLOSE-delay(CLOSE,1)),24,1)*100###
        return ewma(Max(self.close-delay(self.close,1),0),24,1)/ewma(abs(self.close-delay(self.close,1)),24,1)*100
    
    def alpha_68(self):   #1790
        ####ewma(((HIGH+LOW)/2-(delay(HIGH,1)+delay(LOW,1))/2)*(HIGH-LOW)/VOLUME,15,2)###
        return ewma(((self.high+self.low)/2-(delay(self.high,1)+delay(self.low,1))/2)*(self.high-self.low)/self.volume,15,2)
    
    def alpha_69(self):  
        ####(ts_sum(DTM,20)>ts_sum(DBM,20)？ (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DTM,20)： (ts_sum(DTM,20)=ts_sum(DBM,20)？0： (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DBM,20)))###
        ####DTM (OPEN<=delay(OPEN,1)?0:MAX((HIGH-OPEN),(OPEN-delay(OPEN,1))))
        ####DBM (OPEN>=delay(OPEN,1)?0:MAX((OPEN-LOW),(OPEN-delay(OPEN,1))))
        cond1 = (self.open <= delay(self.open,1))
        cond2 = (self.open >= delay(self.open,1))
        
        DTM = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        #DTM[cond1] = 0
        DTM[~cond1] = Max2((self.high-self.open),(self.open-delay(self.open,1)))
        
        DBM = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        #DBM[cond2] = 0
        DBM[~cond2] = Max2((self.open-self.low),(self.open-delay(self.open,1)))
        
        cond3 = (ts_sum(DTM,20) > ts_sum(DBM,20))
        cond4 = (ts_sum(DTM,20)== ts_sum(DBM,20))
        cond5 = (ts_sum(DTM,20) < ts_sum(DBM,20))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond3] = (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DTM,20)
        #part[cond4] = 0
        part[cond5] = (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DBM,20)
        return part
    
    def alpha_70(self):   #1759
        ####stddev(AMOUNT,6)###
        return stddev(self.amount,6)
    
    def alpha_71(self):   #1630
        ####(CLOSE-MEAN(CLOSE,24))/MEAN(CLOSE,24)*100###
        return (self.close-Mean(self.close,24))/Mean(self.close,24)*100
    
    def alpha_72(self):   #1759
        ####ewma((ts_max(HIGH,6)-CLOSE)/(ts_max(HIGH,6)-ts_min(LOW,6))*100,15,1)###
        return ewma((ts_max(self.high,6)-self.close)/(ts_max(self.high,6)-ts_min(self.low,6))*100,15,1)
    
    def alpha_73(self):   #1729
        ####((ts_rank(decay_linear(decay_linear(correlation((CLOSE), VOLUME, 10), 16), 4), 5) - rank(decay_linear(correlation(VWAP, MEAN(VOLUME,30), 4),3))) * -1)###
        return ((ts_rank(decay_linear(decay_linear(correlation((self.close), self.volume, 10), 16), 4), 5) - rank(decay_linear(correlation(self.vwap, Mean(self.volume,30), 4),3))) * -1) 
    
    def alpha_74(self):   #1402
        ####(rank(correlation(ts_sum(((LOW * 0.35) + (VWAP * 0.65)), 20), ts_sum(MEAN(VOLUME,40), 20), 7)) + rank(correlation(rank(VWAP), rank(VOLUME), 6)))###
        return (rank(correlation(ts_sum(((self.low * 0.35) + (self.vwap * 0.65)), 20), ts_sum(Mean(self.volume,40), 20), 7)) + rank(correlation(rank(self.vwap), rank(self.volume), 6)))
    
    # def alpha_75(self):  
    #     ####COUNT(CLOSE>OPEN & BANCHMARKINDEXCLOSE
    #     cond1 = ((self.close>self.open)&(self.benchmark_close<self.benchmark_open))
    #     cond2 = (self.benchmark_close<self.benchmark_open)
    #     part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
    #     part1[cond1] = 1
    #     part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
    #     part2[cond2] = 1     
    #     return Count(part1,50)/Count(part2,50)
    
    def alpha_76(self):   #1650
        ####stddev(abs((CLOSE/delay(CLOSE,1)-1))/VOLUME,20)/MEAN(abs((CLOSE/delay(CLOSE,1)-1))/VOLUME,20)###
        return stddev(abs((self.close/delay(self.close,1)-1))/self.volume,20)/Mean(abs((self.close/delay(self.close,1)-1))/self.volume,20)
    
    def alpha_77(self):   #1797
        #### MIN(rank(decay_linear(((((HIGH + LOW) / 2) + HIGH) - (VWAP + HIGH)), 20)),rank(decay_linear(correlation(((HIGH + LOW) / 2), MEAN(VOLUME,40), 3), 6)))###
        return  Min2(rank(decay_linear(((((self.high + self.low) / 2) + self.high) - (self.vwap + self.high)), 20)),rank(decay_linear(correlation(((self.high + self.low) / 2), Mean(self.volume,40), 3), 6)))
       
    def alpha_78(self):   #1637
        ####((HIGH+LOW+CLOSE)/3-MA((HIGH+LOW+CLOSE)/3,12))/(0.015*MEAN(abs(CLOSE-MEAN((HIGH+LOW+CLOSE)/3,12)),12))###
        return ((self.high+self.low+self.close)/3-Mean((self.high+self.low+self.close)/3,12))/(0.015*Mean(abs(self.close-Mean((self.high+self.low+self.close)/3,12)),12))
    
    def alpha_79(self):   #1789
        ####ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100###
        return ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100
    
    def alpha_80(self):   #1776
        ####(VOLUME-delay(VOLUME,5))/delay(VOLUME,5)*100###
        return (self.volume-delay(self.volume,5))/delay(self.volume,5)*100
    
    def alpha_81(self):   #1797
        ####ewma(VOLUME,21,2)###
        return ewma(self.volume,21,2)
    
    def alpha_82(self):   #1759
        ####ewma((ts_max(HIGH,6)-CLOSE)/(ts_max(HIGH,6)-ts_min(LOW,6))*100,20,1)###
        return ewma((ts_max(self.high,6)-self.close)/(ts_max(self.high,6)-ts_min(self.low,6))*100,20,1)
    
    def alpha_83(self):   #1766
        ####(-1 * rank(COVIANCE(rank(HIGH), rank(VOLUME), 5)))###
        return (-1 * rank(covariance(rank(self.high), rank(self.volume), 5)))
    
    def alpha_84(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:(CLOSE
        cond1 = (self.close > delay(self.close,1))
        cond2 = (self.close < delay(self.close,1))
        cond3 = (self.close == delay(self.close,1))  
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = self.volume
        part[cond2] = 0
        part[cond3] = -self.volume 
        return ts_sum(part, 20)
    
    def alpha_85(self):   #1657
        ####(ts_rank((VOLUME / MEAN(VOLUME,20)), 20) * ts_rank((-1 * delta(CLOSE, 7)), 8))###
        return (ts_rank((self.volume / Mean(self.volume,20)), 20) * ts_rank((-1 * delta(self.close, 7)), 8))
    
    def alpha_86(self):  
        ####((0.25 < (((delay(CLOSE, 20) - delay(CLOSE, 10)) / 10) - ((delay(CLOSE, 10) - CLOSE) / 10))) ? (-1 * 1) :(((((delay(CLOSE, 20) - delay(CLOSE, 10)) / 10) - ((delay(CLOSE, 10) - CLOSE) / 10)) < 0) ?1 : ((-1 * 1) *(CLOSE - delay(CLOSE, 1)))))
        A = (((delay(self.close, 20) - delay(self.close, 10)) / 10) - ((delay(self.close, 10) - self.close) / 10))
        cond1 = (A > 0.25)
        cond2 = (A < 0.0)
        cond3 = (A >= 0) & (A <= 0.25)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = -1
        part[cond2] = 1
        part[cond3] = -1*(self.close - delay(self.close, 1))
        return part

    def alpha_87(self):   #1741
        ####((rank(decay_linear(delta(VWAP, 4), 7)) + ts_rank(decay_linear(((((LOW * 0.9) + (LOW * 0.1)) - VWAP) /(OPEN - ((HIGH + LOW) / 2))), 11), 7)) * -1)###
        return ((rank(decay_linear(delta(self.vwap, 4), 7)) + ts_rank(decay_linear(((((self.low * 0.9) + (self.low * 0.1)) - self.vwap) /(self.open - ((self.high + self.low) / 2))), 11), 7)) * -1)
  
    def alpha_88(self):   #1745
        ####(CLOSE-delay(CLOSE,20))/delay(CLOSE,20)*100###
        return (self.close-delay(self.close,20))/delay(self.close,20)*100
    
    def alpha_89(self):   #1797
        ####2*(ewma(CLOSE,13,2)-ewma(CLOSE,27,2)-ewma(ewma(CLOSE,13,2)-ewma(CLOSE,27,2),10,2))###
        return 2*(ewma(self.close,13,2)-ewma(self.close,27,2)-ewma(ewma(self.close,13,2)-ewma(self.close,27,2),10,2))
    
    def alpha_90(self):   #1745
        ####(rank(correlation(rank(VWAP), rank(VOLUME), 5)) * -1)###
        return (rank(correlation(rank(self.vwap), rank(self.volume), 5)) * -1)
    
    def alpha_91(self):   #1745
        ####((rank((CLOSE - MAX(CLOSE, 5)))*rank(correlation((MEAN(VOLUME,40)), LOW, 5))) * -1)###
        return ((rank((self.close - Max(self.close, 5)))*rank(correlation((Mean(self.volume,40)), self.low, 5))) * -1)
    
    def alpha_92(self):   #1786
        ####(MAX(rank(decay_linear(delta(((CLOSE * 0.35) + (VWAP *0.65)), 2), 3)),ts_rank(decay_linear(abs(correlation((MEAN(VOLUME,180)), CLOSE, 13)), 5), 15)) * -1)###
        return (Max2(rank(decay_linear(delta(((self.close * 0.35) + (self.vwap *0.65)), 2), 3)),ts_rank(decay_linear(abs(correlation((Mean(self.volume,180)), self.close, 13)), 5), 15)) * -1)
    
    def alpha_93(self):  
        ####ts_sum((OPEN>=delay(OPEN,1)?0:MAX((OPEN-LOW),(OPEN-delay(OPEN,1)))),20)###
        cond = (self.open >= delay(self.open,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        #part[cond] = 0
        part[~cond] = Max2((self.open-self.low),(self.open-delay(self.open,1)))
        return ts_sum(part, 20)
    
    def alpha_94(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:(CLOSE
        cond1 = (self.close > delay(self.close,1))
        cond2 = (self.close < delay(self.close,1))
        cond3 = (self.close == delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = self.volume
        part[cond2] = -1*self.volume
        #part[cond3] = 0
        return ts_sum(part, 30)
    
    def alpha_95(self):   #1657
        ####stddev(AMOUNT,20)###
        return stddev(self.amount,20)
    
    def alpha_96(self):   #1736
        ####ewma(ewma((CLOSE-ts_min(LOW,9))/(ts_max(HIGH,9)-ts_min(LOW,9))*100,3,1),3,1)###
        return ewma(ewma((self.close-ts_min(self.low,9))/(ts_max(self.high,9)-ts_min(self.low,9))*100,3,1),3,1)
    
    def alpha_97(self):   #1729
        ####stddev(VOLUME,10)###
        return stddev(self.volume,10)
    
    def alpha_98(self):  
        ####((((delta((ts_sum(CLOSE, 100) / 100), 100) / delay(CLOSE, 100)) < 0.05) || ((delta((ts_sum(CLOSE, 100) / 100), 100) /delay(CLOSE, 100)) == 0.05)) ? (-1 * (CLOSE - ts_min(CLOSE, 100))) : (-1 * delta(CLOSE, 3)))###
        cond = (delta(ts_sum(self.close,100)/100, 100)/delay(self.close, 100) <= 0.05)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1 * (self.close - ts_min(self.close, 100))
        part[~cond] = -1 * delta(self.close, 3)
        return part
    
    def alpha_99(self):   #1766
        ####(-1 * rank(covariance(rank(self.close), rank(self.volume), 5)))###
        return (-1 * rank(covariance(rank(self.close), rank(self.volume), 5)))
    
    def alpha_100(self):   #1657
        ####stddev(self.volume,20)###
        return stddev(self.volume,20)
    
    def alpha_101(self):  
        ###((rank(correlation(CLOSE, ts_sum(MEAN(VOLUME,30), 37), 15)) < rank(correlation(rank(((HIGH * 0.1) + (VWAP * 0.9))),rank(VOLUME), 11))) * -1)
        rank1 = rank(correlation(self.close, ts_sum(Mean(self.volume,30), 37), 15))
        rank2 = rank(correlation(rank(((self.high * 0.1) + (self.vwap * 0.9))),rank(self.volume), 11))
        cond = (rank1<rank2)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1
        #part[~cond] = 0
        return part
    
    def alpha_102(self):   #1790
        ####ewma(MAX(VOLUME-delay(VOLUME,1),0),6,1)/ewma(abs(VOLUME-delay(VOLUME,1)),6,1)*100###
        return ewma(Max(self.volume-delay(self.volume,1),0),6,1)/ewma(abs(self.volume-delay(self.volume,1)),6,1)*100
    
    def alpha_103(self):  
        ####((20-LOWDAY(LOW,20))/20)*100###
        return ((20-Lowday(self.low,20))/20)*100
    
    def alpha_104(self):   #1657
        ####(-1 * (delta(correlation(HIGH, VOLUME, 5), 5) * rank(stddev(CLOSE, 20))))###
        return (-1 * (delta(correlation(self.high, self.volume, 5), 5) * rank(stddev(self.close, 20))))
    
    def alpha_105(self):   #1729
        ####(-1 * correlation(rank(OPEN), rank(VOLUME), 10))###
        return (-1 * correlation(rank(self.open), rank(self.volume), 10))
    
    def alpha_106(self):   #1745
        ####CLOSE-delay(CLOSE,20)###
        return self.close-delay(self.close,20)
    
    def alpha_107(self):   #1790
        ####(((-1 * rank((OPEN - delay(HIGH, 1)))) * rank((OPEN - delay(CLOSE, 1)))) * rank((OPEN - delay(LOW, 1))))###
        return (((-1 * rank((self.open - delay(self.high, 1)))) * rank((self.open - delay(self.close, 1)))) * rank((self.open - delay(self.low, 1))))
    
    def alpha_108(self):   #1178   
        ####((rank((HIGH - MIN(HIGH, 2)))^rank(correlation((VWAP), (MEAN(VOLUME,120)), 6))) * -1)###
        return ((rank((self.high - Min(self.high, 2)))**rank(correlation((self.vwap), (Mean(self.volume,120)), 6))) * -1)
    
    def alpha_109(self):   #1797
        ####ewma(HIGH-LOW,10,2)/ewma(ewma(HIGH-LOW,10,2),10,2)###
        return ewma(self.high-self.low,10,2)/ewma(ewma(self.high-self.low,10,2),10,2)
    
    def alpha_110(self):   #1650
        ####ts_sum(MAX(0,HIGH-delay(CLOSE,1)),20)/ts_sum(MAX(0,delay(CLOSE,1)-LOW),20)*100###
        return ts_sum(Max(self.high-delay(self.close,1),0),20)/ts_sum(Max(delay(self.close,1)-self.low,0),20)*100
      
    def alpha_111(self):   #1789
        ####ewma(VOL*((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW),11,2)-ewma(VOL*((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW),4,2)###
        return ewma(self.volume*((self.close-self.low)-(self.high-self.close))/(self.high-self.low),11,2)-ewma(self.volume*((self.close-self.low)-(self.high-self.close))/(self.high-self.low),4,2)
    
    def alpha_112(self):  
        ####(ts_sum((CLOSE-delay(CLOSE,1)>0? CLOSE-delay(CLOSE,1):0),12) - ts_sum((CLOSE-delay(CLOSE,1)<0?abs(CLOSE-delay(CLOSE,1)):0),12))/(ts_sum((CLOSE-delay(CLOSE,1)>0?CLOSE-delay(CLOSE,1):0),12) + ts_sum((CLOSE-delay(CLOSE,1)<0?abs(CLOSE-delay(CLOSE,1)):0),12))*100     
        cond = (self.close-delay(self.close,1) > 0)
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = self.close-delay(self.close,1)
        #part1[~cond] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = abs(self.close-delay(self.close,1))
        #part2[cond] = 0
        return (ts_sum(part1,12) - ts_sum(part2,12))/(ts_sum(part1,12) + ts_sum(part2,12))*100
    
    def alpha_113(self):   #1587
        ####(-1 * ((rank((ts_sum(delay(CLOSE, 5), 20) / 20)) * correlation(CLOSE, VOLUME, 2)) * rank(correlation(ts_sum(CLOSE, 5),ts_sum(CLOSE, 20), 2))))###
        return (-1 * ((rank((ts_sum(delay(self.close, 5), 20) / 20)) * correlation(self.close, self.volume, 2)) * rank(correlation(ts_sum(self.close, 5),ts_sum(self.close, 20), 2))))
    
    def alpha_114(self):   #1751
        ####((rank(delay(((HIGH - LOW) / (ts_sum(CLOSE, 5) / 5)), 2)) * rank(rank(VOLUME))) / (((HIGH - LOW) /(ts_sum(CLOSE, 5) / 5)) / (VWAP - CLOSE)))###
        return ((rank(delay(((self.high - self.low) / (ts_sum(self.close, 5) / 5)), 2)) * rank(rank(self.volume))) / (((self.high - self.low) /(ts_sum(self.close, 5) / 5)) / (self.vwap - self.close)))
    
    def alpha_115(self):   #1527
        ####(rank(correlation(((HIGH * 0.9) + (CLOSE * 0.1)), MEAN(VOLUME,30), 10))^rank(correlation(ts_rank(((HIGH + LOW) /2), 4), ts_rank(VOLUME, 10), 7)))###
        return (rank(correlation(((self.high * 0.9) + (self.close * 0.1)), Mean(self.volume,30), 10))**rank(correlation(ts_rank(((self.high + self.low) /2), 4), ts_rank(self.volume, 10), 7)))
    
    # def alpha_116(self):  
    #     ####REGBETA(CLOSE,SEQUENCE,20)###
    #     return 0
    
    def alpha_117(self):   #1786
        ####((ts_rank(VOLUME, 32) * (1 - ts_rank(((CLOSE + HIGH) - LOW), 16))) * (1 - ts_rank(RET, 32)))###
        return ((ts_rank(self.volume, 32) * (1 - ts_rank(((self.close + self.high) - self.low), 16))) * (1 - ts_rank(self.returns, 32)))
    
    def alpha_118(self):   #1657
        ####ts_sum(HIGH-OPEN,20)/ts_sum(OPEN-LOW,20)*100###
        return ts_sum(self.high-self.open,20)/ts_sum(self.open-self.low,20)*100
    
    def alpha_119(self):   #1626
        ####(rank(decay_linear(correlation(VWAP, ts_sum(MEAN(VOLUME,5), 26), 5), 7)) - rank(decay_linear(ts_rank(MIN(correlation(rank(OPEN), rank(MEAN(VOLUME,15)), 21), 9), 7), 8)))###
        return (rank(decay_linear(correlation(self.vwap, ts_sum(Mean(self.volume,5), 26), 5), 7)) - rank(decay_linear(ts_rank(Min(correlation(rank(self.open), rank(Mean(self.volume,15)), 21), 9), 7), 8)))
    
    def alpha_120(self):   #1797
        ####(rank((VWAP - CLOSE)) / rank((VWAP + CLOSE)))###
        return (rank((self.vwap - self.close)) / rank((self.vwap + self.close)))
    
    def alpha_121(self):   #972   数据量较少
        ####((rank((VWAP - MIN(VWAP, 12)))^ts_rank(correlation(ts_rank(VWAP, 20), ts_rank(MEAN(VOLUME,60), 2), 18), 3)) *-1)###
        return ((rank((self.vwap - Min(self.vwap, 12)))**ts_rank(correlation(ts_rank(self.vwap, 20), ts_rank(Mean(self.volume,60), 2), 18), 3)) *-1)
    
    def alpha_122(self):   #1790
        ####(ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2)-delay(ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2),1))/delay(ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2),1)###
        return (ewma(ewma(ewma(log(self.close),13,2),13,2),13,2)-delay(ewma(ewma(ewma(log(self.close),13,2),13,2),13,2),1))/delay(ewma(ewma(ewma(log(self.close),13,2),13,2),13,2),1)
    
    def alpha_123(self):  
        ####((rank(correlation(ts_sum(((HIGH + LOW) / 2), 20), ts_sum(MEAN(VOLUME,60), 20), 9)) < rank(correlation(LOW, VOLUME,6))) * -1)###
        A = rank(correlation(ts_sum(((self.high + self.low) / 2), 20), ts_sum(Mean(self.volume,60), 20), 9))
        B = rank(correlation(self.low, self.volume,6))
        cond = (A < B)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1
        #part[~cond] = 0
        return part
    
    def alpha_124(self):   #1592
        ####(CLOSE - VWAP) / decay_linear(rank(ts_max(CLOSE, 30)),2)###
        return (self.close - self.vwap) / decay_linear(rank(ts_max(self.close, 30)),2)
     
    def alpha_125(self):   #1678
        ####(rank(decay_linear(correlation((VWAP), MEAN(VOLUME,80),17), 20)) / rank(decay_linear(delta(((CLOSE * 0.5) + (VWAP * 0.5)), 3), 16)))###
        return (rank(decay_linear(correlation((self.vwap), Mean(self.volume,80),17), 20)) / rank(decay_linear(delta(((self.close * 0.5) + (self.vwap * 0.5)), 3), 16)))
    
    def alpha_126(self):   #1797
        ####(CLOSE+HIGH+LOW)/3###
        return (self.close+self.high+self.low)/3
    
    def alpha_127(self):  #公式有问题，我们假设mean周期为12
        ####(MEAN((100*(CLOSE-MAX(CLOSE,12))/(MAX(CLOSE,12)))^2),12)^(1/2)###
        return (Mean((100*(self.close-Max(self.close,12))/(Max(self.close,12)))**2,12))**(1/2)
    
    def alpha_128(self):  
        ####100-(100/(1+ts_sum(((HIGH+LOW+CLOSE)/3>delay((HIGH+LOW+CLOSE)/3,1)?(HIGH+LOW+CLOSE)/3*VOLUME:0),14)/ts_sum(((HIGH+LOW+CLOSE)/3
        A = (self.high+self.low+self.close)/3
        cond = (A > delay(A,1))        
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = A*self.volume
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = A*self.volume
        return 100-(100/(1+ts_sum(part1,14)/ts_sum(part2,14)))

    def alpha_129(self):  
        ####ts_sum((CLOSE-delay(CLOSE,1)<0?abs(CLOSE-delay(CLOSE,1)):0),12)###
        cond = ((self.close-delay(self.close,1)) < 0)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = abs(self.close-delay(self.close,1))
        #part[~cond] = 0
        return ts_sum(part, 12)
    
    def alpha_130(self):   #1657
        ####(rank(decay_linear(correlation(((HIGH + LOW) / 2), MEAN(VOLUME,40), 9), 10)) / rank(decay_linear(correlation(rank(VWAP), rank(VOLUME), 7),3)))###
        return (rank(decay_linear(correlation(((self.high + self.low) / 2), Mean(self.volume,40), 9), 10)) / rank(decay_linear(correlation(rank(self.vwap), rank(self.volume), 7),3)))
    
    def alpha_131(self):   #1030   数据量较少
        ####(rank(DELAT(VWAP, 1))^ts_rank(correlation(CLOSE,MEAN(VOLUME,50), 18), 18))###
        return (rank(delta(self.vwap, 1))**ts_rank(correlation(self.close,Mean(self.volume,50), 18), 18))
       
    def alpha_132(self):   #1657
        ####MEAN(AMOUNT,20)###
        return Mean(self.amount,20)
    
    def alpha_133(self):  
        ####((20-HIGHDAY(HIGH,20))/20)*100-((20-LOWDAY(LOW,20))/20)*100###
        return ((20-Highday(self.high,20))/20)*100-((20-Lowday(self.low,20))/20)*100
    
    def alpha_134(self):   #1760
        ####(CLOSE-delay(CLOSE,12))/delay(CLOSE,12)*VOLUME###
        return (self.close-delay(self.close,12))/delay(self.close,12)*self.volume
    
    def alpha_135(self):   #1744
        ####ewma(delay(CLOSE/delay(CLOSE,20),1),20,1)###
        return ewma(delay(self.close/delay(self.close,20),1),20,1)
    
    def alpha_136(self):   #1729
        ####((-1 * rank(delta(RET, 3))) * correlation(OPEN, VOLUME, 10))###
        return ((-1 * rank(delta(self.returns, 3))) * correlation(self.open, self.volume, 10))
    
    def alpha_137(self):  
        ####16*(CLOSE-delay(CLOSE,1)+(CLOSE-OPEN)/2+delay(CLOSE,1)-delay(OPEN,1))/((abs(HIGH-delay(CLOSE,1))>abs(LOW-delay(CLOSE,1)) & abs(HIGH-delay(CLOSE,1))>abs(HIGH-delay(LOW,1))?abs(HIGH-delay(CLOSE,1))+abs(LOW-delay(CLOSE,1))/2+abs(delay(CLOSE,1)-delay(OPEN,1))/4:(abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(LOW,1)) & abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(CLOSE,1))?abs(LOW-delay(CLOSE,1))+abs(HIGH-delay(CLOSE,1))/2+abs(delay(CLOSE,1)-delay(OPEN,1))/4:abs(HIGH-delay(LOW,1))+abs(delay(CLOSE,1)-delay(OPEN,1))/4)))*MAX(abs(HIGH-delay(CLOSE,1)),abs(LOW-delay(CLOSE,1)))
        A = abs(self.high- delay(self.close,1))
        B = abs(self.low - delay(self.close,1))
        C = abs(self.high- delay(self.low,1))
        D = abs(delay(self.close,1)-delay(self.open,1))          
        cond1 = ((A>B) & (A>C))
        cond2 = ((B>C) & (B>A))
        cond3 = ((C>=A) & (C>=B))       
        part0 = 16*(self.close + (self.close - self.open)/2 - delay(self.open,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = A + B/2 + D/4
        part1[cond2] = B + A/2 + D/4
        part1[cond3] = C + D/4     
        return part0/part1*Max2(A,B)

    def alpha_138(self):   #1448
        ####((rank(decay_linear(delta((((LOW * 0.7) + (VWAP *0.3))), 3), 20)) - ts_rank(decay_linear(ts_rank(correlation(ts_rank(LOW, 8), ts_rank(MEAN(VOLUME,60), 17), 5), 19), 16), 7)) * -1)###
        return ((rank(decay_linear(delta((((self.low * 0.7) + (self.vwap *0.3))), 3), 20)) - ts_rank(decay_linear(ts_rank(correlation(ts_rank(self.low, 8), ts_rank(Mean(self.volume,60), 17), 5), 19), 16), 7)) * -1)
    
    def alpha_139(self):   #1729
        ####(-1 * correlation(OPEN, VOLUME, 10))###
        return (-1 * correlation(self.open, self.volume, 10))
    
    def alpha_140(self):   #1797
        ####MIN(rank(decay_linear(((rank(OPEN) + rank(LOW)) - (rank(HIGH) + rank(CLOSE))), 8)), ts_rank(decay_linear(correlation(ts_rank(CLOSE, 8), ts_rank(MEAN(VOLUME,60), 20), 8), 7), 3))###
        return Min2(rank(decay_linear(((rank(self.open) + rank(self.low)) - (rank(self.high) + rank(self.close))), 8)), ts_rank(decay_linear(correlation(ts_rank(self.close, 8), ts_rank(Mean(self.volume,60), 20), 8), 7), 3))
    
    def alpha_141(self):   #1637
        ####(rank(correlation(rank(HIGH), rank(MEAN(VOLUME,15)), 9))* -1)###
        return (rank(correlation(rank(self.high), rank(Mean(self.volume,15)), 9))* -1)
    
    def alpha_142(self):   #1657
        ####(((-1 * rank(ts_rank(CLOSE, 10))) * rank(delta(delta(CLOSE, 1), 1))) * rank(ts_rank((VOLUME/MEAN(VOLUME,20)), 5)))###
        return (((-1 * rank(ts_rank(self.close, 10))) * rank(delta(delta(self.close, 1), 1))) * rank(ts_rank((self.volume/Mean(self.volume,20)), 5)))
    
    # def alpha_143(self):  
    #     ####CLOSE>delay(CLOSE,1)?(CLOSE-delay(CLOSE,1))/delay(CLOSE,1)*SELF:SELF###
    #     return 0
    
    def alpha_144(self):  
        ####SUMIF(abs(CLOSE/delay(CLOSE,1)-1)/AMOUNT,20,CLOSE
        cond = (self.close<delay(self.close,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = abs(self.close/delay(self.close,1)-1)/self.amount
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[cond] = 1
        return Sumif(part1,20)/Count(part2,20)
    
    def alpha_145(self):   #1617
        ####(MEAN(VOLUME,9)-MEAN(VOLUME,26))/MEAN(VOLUME,12)*100###
        return (Mean(self.volume,9)-Mean(self.volume,26))/Mean(self.volume,12)*100
    
    def alpha_146(self):   #1650  公式有问题
        ####MEAN((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-ewma((CLOSE-delay(CLOSE,1))/delay(CLOSE,1),61,2),20)*((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-ewma((CLOSE-delay(CLOSE,1))/delay(CLOSE,1),61,2))/ewma(((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-ewma((CLOSE-delay(CLOSE,1))/delay(CLOSE,1),61,2)))^2,61,2)###
        return Mean((self.close-delay(self.close,1))/delay(self.close,1)-ewma((self.close-delay(self.close,1))/delay(self.close,1),61,2),20)*((self.close-delay(self.close,1))/delay(self.close,1)-ewma((self.close-delay(self.close,1))/delay(self.close,1),61,2))/ewma(((self.close-delay(self.close,1))/delay(self.close,1)-((self.close-delay(self.close,1))/delay(self.close,1)-ewma((self.close-delay(self.close,1))/delay(self.close,1),61,2)))**2,61,2)

    # def alpha_147(self):  
    #     ####REGBETA(MEAN(CLOSE,12),SEQUENCE(12))###
    #     return 0
    
    def alpha_148(self):  
        ####((rank(correlation((OPEN), ts_sum(MEAN(VOLUME,60), 9), 6)) < rank((OPEN - ts_min(OPEN, 14)))) * -1)###
        cond = (rank(correlation((self.open), ts_sum(Mean(self.volume,60), 9), 6)) < rank((self.open - ts_min(self.open, 14))))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1
        #part[~cond] = 0
        return part
    
    # def alpha_149(self):  
    #     ####REGBETA(FILTER(CLOSE/delay(CLOSE,1)-1,BANCHMARKINDEXCLOSE
        # return 0
    
    def alpha_150(self):   #1797
        ####(CLOSE+HIGH+LOW)/3*VOLUME###
        return (self.close+self.high+self.low)/3*self.volume
    
    def alpha_151(self):   #1745
        ####ewma(CLOSE-delay(CLOSE,20),20,1)###
        return ewma(self.close-delay(self.close,20),20,1)
    
    def alpha_152(self):   #1559
        ####ewma(MEAN(delay(ewma(delay(CLOSE/delay(CLOSE,9),1),9,1),1),12)-MEAN(delay(ewma(delay(CLOSE/delay(CLOSE,9),1),9,1),1),26),9,1)###
        return ewma(Mean(delay(ewma(delay(self.close/delay(self.close,9),1),9,1),1),12)-Mean(delay(ewma(delay(self.close/delay(self.close,9),1),9,1),1),26),9,1)
    
    def alpha_153(self):   #1630
        ####(MEAN(CLOSE,3)+MEAN(CLOSE,6)+MEAN(CLOSE,12)+MEAN(CLOSE,24))/4###
        return (Mean(self.close,3)+Mean(self.close,6)+Mean(self.close,12)+Mean(self.close,24))/4
    
    def alpha_154(self):  
        ####(((VWAP - MIN(VWAP, 16))) < (correlation(VWAP, MEAN(VOLUME,180), 18)))###
        cond = (((self.vwap - Min(self.vwap, 16))) < (correlation(self.vwap, Mean(self.volume,180), 18)))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1
        return part
    
    def alpha_155(self):   #1797
        ####ewma(VOLUME,13,2)-ewma(VOLUME,27,2)-ewma(ewma(VOLUME,13,2)-ewma(VOLUME,27,2),10,2)###
        return ewma(self.volume,13,2)-ewma(self.volume,27,2)-ewma(ewma(self.volume,13,2)-ewma(self.volume,27,2),10,2)
    
    def alpha_156(self):   #1776
        ####(MAX(rank(decay_linear(delta(VWAP, 5), 3)), rank(decay_linear(((delta(((OPEN * 0.15) + (LOW *0.85)),2) / ((OPEN * 0.15) + (LOW * 0.85))) * -1), 3))) * -1)###
        return (Max2(rank(decay_linear(delta(self.vwap, 5), 3)), rank(decay_linear(((delta(((self.open * 0.15) + (self.low *0.85)),2) / ((self.open * 0.15) + (self.low * 0.85))) * -1), 3))) * -1)
    
    def alpha_157(self):   #1764
        ####(MIN(product(rank(rank(log(ts_sum(ts_min(rank(rank((-1 * rank(delta((CLOSE - 1), 5))))), 2), 1)))), 1), 5) + ts_rank(delay((-1 * RET), 6), 5))###
        return (Min(product(rank(rank(log(ts_sum(ts_min(rank(rank((-1 * rank(delta((self.close - 1), 5))))), 2), 1)))), 1), 5) + ts_rank(delay((-1 * self.returns), 6), 5))
    
    def alpha_158(self):   #1797
        ####((HIGH-ewma(CLOSE,15,2))-(LOW-ewma(CLOSE,15,2)))/CLOSE###
        return ((self.high-ewma(self.close,15,2))-(self.low-ewma(self.close,15,2)))/self.close
    
    def alpha_159(self):   #1630
        ####((CLOSE-ts_sum(MIN(LOW,delay(CLOSE,1)),6))/ts_sum(MAX(HGIH,delay(CLOSE,1))-MIN(LOW,delay(CLOSE,1)),6)*12*24+(CLOSE-ts_sum(MIN(LOW,delay(CLOSE,1)),12))/ts_sum(MAX(HGIH,delay(CLOSE,1))-MIN(LOW,delay(CLOSE,1)),12)*6*24+(CLOSE-ts_sum(MIN(LOW,delay(CLOSE,1)),24))/ts_sum(MAX(HGIH,delay(CLOSE,1))-MIN(LOW,delay(CLOSE,1)),24)*6*24)*100/(6*12+6*24+12*24)###
        return ((self.close-ts_sum(Min2(self.low,delay(self.close,1)),6))/ts_sum(Max2(self.high,delay(self.close,1))-Min2(self.low,delay(self.close,1)),6)*12*24+(self.close-ts_sum(Min2(self.low,delay(self.close,1)),12))/ts_sum(Max2(self.high,delay(self.close,1))-Min2(self.low,delay(self.close,1)),12)*6*24+(self.close-ts_sum(Min2(self.low,delay(self.close,1)),24))/ts_sum(Max2(self.high,delay(self.close,1))-Min2(self.low,delay(self.close,1)),24)*6*24)*100/(6*12+6*24+12*24)
    
    def alpha_160(self):  
        ####ewma((CLOSE<=delay(CLOSE,1)?stddev(CLOSE,20):0),20,1)###
        cond = (self.close<=delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = stddev(self.close,20)
        #part[~cond] = 0
        return ewma(part, 20, 1)
    
    def alpha_161(self):   #1714
        ####MEAN(MAX(MAX((HIGH-LOW),abs(delay(CLOSE,1)-HIGH)),abs(delay(CLOSE,1)-LOW)),12)###
        return Mean(Max2(Max2((self.high-self.low),abs(delay(self.close,1)-self.high)),abs(delay(self.close,1)-self.low)),12)
    
    def alpha_162(self):   #1789
        ####(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100-MIN(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100,12))/(MAX(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100,12)-MIN(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100,12))###
        return (ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100-Min(ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100,12))/(ewma(ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100,12,1)-Min(ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100,12))
    
    def alpha_163(self):   #1657
        ####rank(((((-1 * RET) * MEAN(VOLUME,20)) * VWAP) * (HIGH - CLOSE)))###
        return rank(((((-1 * self.returns) * Mean(self.volume,20)) * self.vwap) * (self.high - self.close)))
    
    def alpha_164(self):  
        ####ewma(( ((CLOSE>delay(CLOSE,1))?1/(CLOSE-delay(CLOSE,1)):1) - MIN( ((CLOSE>delay(CLOSE,1))?1/(CLOSE-delay(CLOSE,1)):1) ,12) )/(HIGH-LOW)*100,13,2)###
        cond = (self.close>delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1/(self.close-delay(self.close,1))
        part[~cond] = 1
        return ewma((part - Min(part,12))/(self.high-self.low)*100, 13, 2)
    
    # def alpha_165(self):  
    #     ####MAX(SUMAC(CLOSE-MEAN(CLOSE,48)))-MIN(SUMAC(CLOSE-MEAN(CLOSE,48)))/stddev(CLOSE,48)###
        
    #     return 0
    
    # def alpha_166(self):  #公式有问题
        
    #     return 0

    def alpha_167(self):  
        ####ts_sum((CLOSE-delay(CLOSE,1)>0?CLOSE-delay(CLOSE,1):0),12)###
        cond = (self.close > delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = self.close-delay(self.close,1)
        #part[~cond] = 0
        return ts_sum(part,12)
    
    def alpha_168(self):   #1657
        ####(-1*VOLUME/MEAN(VOLUME,20))###
        return (-1*self.volume/Mean(self.volume,20))
    
    def alpha_169(self):   #1610
        ####ewma(MEAN(delay(ewma(CLOSE-delay(CLOSE,1),9,1),1),12)-MEAN(delay(ewma(CLOSE-delay(CLOSE,1),9,1),1),26),10,1)###
        return ewma(Mean(delay(ewma(self.close-delay(self.close,1),9,1),1),12)-Mean(delay(ewma(self.close-delay(self.close,1),9,1),1),26),10,1)
    
    def alpha_170(self):   #1657
        ####((((rank((1 / CLOSE)) * VOLUME) / MEAN(VOLUME,20)) * ((HIGH * rank((HIGH - CLOSE))) / (ts_sum(HIGH, 5) /5))) - rank((VWAP - delay(VWAP, 5))))###
        return ((((rank((1 / self.close)) * self.volume) / Mean(self.volume,20)) * ((self.high * rank((self.high - self.close))) / (ts_sum(self.high, 5) /5))) - rank((self.vwap - delay(self.vwap, 5))))
   
    def alpha_171(self):   #1789
        ####((-1 * ((LOW - CLOSE) * (OPEN^5))) / ((CLOSE - HIGH) * (CLOSE^5)))###
        return ((-1 * ((self.low - self.close) * (self.open**5))) / ((self.close - self.high) * (self.close**5)))
    
    def alpha_172(self):  
        ####MEAN(abs(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)-ts_sum((HD>0 &HD>LD)?HD:0,14)*100/ts_sum(TR,14))/(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)+ts_sum((HD>0 &HD>LD)?HD:0,14)*100/ts_sum(TR,14))*100,6)
        TR = Max2(Max2(self.high-self.low,abs(self.high-delay(self.close,1))),abs(self.low-delay(self.close,1)))
        HD = self.high-delay(self.high,1)
        LD = delay(self.low,1)-self.low
        cond1 = ((LD>0) & (LD>HD))
        cond2 = ((HD>0) & (HD>LD)) 
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = LD
        #part1[~cond1] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[cond2] = HD
        #part2[~cond2] = 0
        return Mean(abs(ts_sum(part1,14)*100/ts_sum(TR,14)-ts_sum(part2,14)*100/ts_sum(TR,14))/(ts_sum(part1,14)*100/ts_sum(TR,14)+ts_sum(part2,14)*100/ts_sum(TR,14))*100,6)
    
    def alpha_173(self):   #1797
        ####3*ewma(CLOSE,13,2)-2*ewma(ewma(CLOSE,13,2),13,2)+ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2)###
        return 3*ewma(self.close,13,2)-2*ewma(ewma(self.close,13,2),13,2)+ewma(ewma(ewma(log(self.close),13,2),13,2),13,2)
    
    def alpha_174(self):  
        ####ewma((CLOSE>delay(CLOSE,1)?stddev(CLOSE,20):0),20,1)###
        cond = (self.close>delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = stddev(self.close,20)
        #part[~cond] = 0
        return ewma(part,20,1)
    
    def alpha_175(self):   #1759
        ####MEAN(MAX(MAX((HIGH-LOW),abs(delay(CLOSE,1)-HIGH)),abs(delay(CLOSE,1)-LOW)),6)###
        return Mean(Max2(Max2((self.high-self.low),abs(delay(self.close,1)-self.high)),abs(delay(self.close,1)-self.low)),6)
    
    def alpha_176(self):   #1678
        ####correlation(rank(((CLOSE - ts_min(LOW, 12)) / (ts_max(HIGH, 12) - ts_min(LOW,12)))), rank(VOLUME), 6)###
        return correlation(rank(((self.close - ts_min(self.low, 12)) / (ts_max(self.high, 12) - ts_min(self.low,12)))), rank(self.volume), 6)
    
    def alpha_177(self):  
        ####((20-HIGHDAY(HIGH,20))/20)*100###
        return ((20-Highday(self.high,20))/20)*100
    
    def alpha_178(self):   #1790
        ####(CLOSE-delay(CLOSE,1))/delay(CLOSE,1)*VOLUME###
        return (self.close-delay(self.close,1))/delay(self.close,1)*self.volume
    
    def alpha_179(self):   #1421   数据量较少
        ####(rank(correlation(VWAP, VOLUME, 4)) *rank(correlation(rank(LOW), rank(MEAN(VOLUME,50)), 12)))###
        return (rank(correlation(self.vwap, self.volume, 4)) *rank(correlation(rank(self.low), rank(Mean(self.volume,50)), 12)))
    
    def alpha_180(self):  #指标有问题
        ####((MEAN(VOLUME,20) < VOLUME) ? ((-1 * ts_rank(abs(delta(CLOSE, 7)), 60)) * sign(delta(CLOSE, 7)) : (-1 *VOLUME)))
        cond = (Mean(self.volume,20) < self.volume)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = (-1 * ts_rank(abs(delta(self.close, 7)), 60)) * sign(delta(self.close, 7)) 
        part[~cond] = -1 * self.volume
        return part
    
    def alpha_181(self):   #1532  公式有问题，假设后面的sum周期为20
        ####ts_sum(((CLOSE/delay(CLOSE,1)-1)-MEAN((CLOSE/delay(CLOSE,1)-1),20))-(BANCHMARKINDEXCLOSE-MEAN(BANCHMARKINDEXCLOSE,20))^2,20)/ts_sum((BANCHMARKINDEXCLOSE-MEAN(BANCHMARKINDEXCLOSE,20))^3)###
        return ts_sum(((self.close/delay(self.close,1)-1)-Mean((self.close/delay(self.close,1)-1),20))-(self.benchmark_close-Mean(self.benchmark_close,20))**2,20)/ts_sum(((self.benchmark_close-Mean(self.benchmark_close,20))**3),20)
    
    # def alpha_182(self):  
    #     ####COUNT((CLOSE>OPEN & BANCHMARKINDEXCLOSE>BANCHMARKINDEXOPEN)OR(CLOSE
    #     cond1 = ((self.close>self.open) & (self.benchmark_close>self.benchmark_open))
    #     cond2 = ((self.close<self.open) & (self.benchmark_close<self.benchmark_open))
    #     part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
    #     part[cond1] = 1
    #     part[cond2] = 1
    #     return Count(part,20)/20
    
    # def alpha_183(self):  
    #     ####MAX(SUMAC(CLOSE-MEAN(CLOSE,24)))-MIN(SUMAC(CLOSE-MEAN(CLOSE,24)))/stddev(CLOSE,24)###
    #     return 0
    
    def alpha_184(self):   #983   数据量较少
        ####(rank(correlation(delay((OPEN - CLOSE), 1), CLOSE, 200)) + rank((OPEN - CLOSE)))###
        return (rank(correlation(delay((self.open - self.close), 1), self.close, 200)) + rank((self.open - self.close)))
    
    def alpha_185(self):   #1797
        ####rank((-1 * ((1 - (OPEN / CLOSE))^2)))###
        return rank((-1 * ((1 - (self.open / self.close))**2)))
    
    def alpha_186(self):  
        ####(MEAN(abs(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)-ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))/(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)+ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))*100,6)+delay(MEAN(abs(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)-ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))/(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)+ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))*100,6),6))/2
        TR = Max2(Max2(self.high-self.low,abs(self.high-delay(self.close,1))),abs(self.low-delay(self.close,1)))
        HD = self.high-delay(self.high,1)
        LD = delay(self.low,1)-self.low
        cond1 = ((LD>0) & (LD>HD))
        cond2 = ((HD>0) & (HD>LD)) 
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = LD
        #part1[~cond1] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[cond2] = HD
        #part2[~cond2] = 0
        return (Mean(abs(ts_sum(part1,14)*100/ts_sum(TR,14)-ts_sum(part2,14)*100/ts_sum(TR,14))/(ts_sum(part1,14)*100/ts_sum(TR,14)+ts_sum(part2,14)*100/ts_sum(TR,14))*100,6)+delay(Mean(abs(ts_sum(part1,14)*100/ts_sum(TR,14)-ts_sum(part2,14)*100/ts_sum(TR,14))/(ts_sum(part1,14)*100/ts_sum(TR,14)+ts_sum(part2,14)*100/ts_sum(TR,14))*100,6),6))/2
    
    def alpha_187(self):  
        ####ts_sum((OPEN<=delay(OPEN,1)?0:MAX((HIGH-OPEN),(OPEN-delay(OPEN,1)))),20)###
        cond = (self.open<=delay(self.open,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 0
        part[~cond] = Max2((self.high-self.open),(self.open-delay(self.open,1)))
        return ts_sum(part,20) 
    
    def alpha_188(self):   #1797
        ####((HIGH-LOW–ewma(HIGH-LOW,11,2))/ewma(HIGH-LOW,11,2))*100###
        return ((self.high-self.low-ewma(self.high-self.low,11,2))/ewma(self.high-self.low,11,2))*100
    
    def alpha_189(self):   #1721
        ####MEAN(abs(CLOSE-MEAN(CLOSE,6)),6)###
        return Mean(abs(self.close-Mean(self.close,6)),6)
    
    def alpha_190(self):  #公式有大问题,
        ####log((COUNT( CLOSE/delay(CLOSE,1)>((CLOSE/delay(CLOSE,19))^(1/20)-1) ,20)-1)*(SUMIF((CLOSE/delay(CLOSE,1)-((CLOSE/delay(CLOSE,19))^(1/20)-1))^2,20,CLOSE/delay(CLOSE,1)<(CLOSE/delay(CLOSE,19))^(1/20)-1))/((COUNT((CLOSE/delay(CLOSE,1)<(CLOSE/delay(CLOSE,19))^(1/20)-1),20))*(SUMIF((CLOSE/delay(CLOSE,1)-((CLOSE/delay(CLOSE,19))^(1/20)-1))^2,20,CLOSE/delay(CLOSE,1)>(CLOSE/delay(CLOSE,19))^(1/20)-1))))
        '''
        cond = ((self.close/delay(self.close,1)) > ((self.close/delay(self.close,19))**(1/20)-1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 1 #COUNT
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = (self.close/delay(self.close,1)-((self.close/delay(self.close,19))**(1/20)-1))**2#SUMIF
        part3 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part3[~cond] = 1 #COUNT
        part4 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part4[cond] = (self.close/delay(self.close,1)-((self.close/delay(self.close,19))**(1/20)-1))**2#SUMIF
        return log((Count(part1,20))*Sumif(part2,20)/(Count(part3,20)*Sumif(part4,20)))'''
        # return 0
    
    def alpha_191(self):   #1721
        ####((correlation(MEAN(VOLUME,20), LOW, 5) + ((HIGH + LOW) / 2)) - CLOSE)###
        return ((correlation(Mean(self.volume,20), self.low, 5) + ((self.high + self.low) / 2)) - self.close)



class Alphas_ind9(object):
    def __init__(self):
        self.open = self.get_df_data('open') 
        self.high = self.get_df_data('high') 
        self.low = self.get_df_data('low')   
        self.close = self.get_df_data('close') 
        self.volume = self.get_df_data('volume')
        self.returns = np.log(self.close/self.close.shift(1)) 
        self.vwap = self.get_df_data('amount')/self.volume 
        self.cap = self.get_df_data('total_mv')
        self.amount = self.get_df_data('amount')
        self.get_bencheck()

    def get_df_data(self, name) :
        root = r'data\stock_data\daily\consentrate_price'
        file = os.path.join(root, f'{name}.pkl.gzip')
        data = pd.read_pickle(file)
        return data

    def get_bencheck(self):
        hs300  = ak.stock_zh_index_daily(symbol="sh000001")
        hs300.index = pd.to_datetime(hs300['date'].values)
        hs300oc = hs300[['open','close']].astype(float)
        hs300oc = hs300oc[hs300oc.index>'2001-1-01']
        # hs300oc.loc[self.close.index[-1]] = [0,0]
        self.benchmark_close = pd.DataFrame(np.expand_dims(hs300oc['close'], axis=1)*np.ones(self.close.shape), index=self.close.index, columns=self.close.columns)
        self.benchmark_open = pd.DataFrame(np.expand_dims(hs300oc['open'], axis=1)*np.ones(self.close.shape), index=self.close.index, columns=self.close.columns)

    def alpha_9n1(self): #平均1751个数据
        ##### (-1 * correlation(rank(delta(log(VOLUME), 1)), rank(((CLOSE - OPEN) / OPEN)), 6))#### 
        return (-1 * correlation(rank(delta(log(self.volume), 1)), rank(((self.close - self.open) / self.open)), 6))
    
    def alpha_9n2(self): #1783
        ##### -1 * delta((((close-low)-(high-close))/(high-low)),1))####
        return -1*delta((((self.close-self.low)-(self.high-self.close))/(self.high-self.low)),1) 
    
    def alpha_9n3(self): 
        ##### ts_sum((CLOSE=delay(CLOSE,1)?0:CLOSE-(CLOSE>delay(CLOSE,1)?MIN(LOW,delay(CLOSE,1)):MAX(HIGH,delay(CLOSE,1)))),6) ####
        cond1 = (self.close == delay(self.close,1))
        cond2 = (self.close > delay(self.close,1))
        cond3 = (self.close < delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index=self.close.index)
        part[cond1] = 0
        part[cond2] = self.close - Min2(self.low,delay(self.close,1))
        part[cond3] = self.close - Max2(self.high,delay(self.close,1))
        return ts_sum(part, 6)
    
    def alpha_9n4(self):  
        #####((((ts_sum(CLOSE, 8) / 8) + stddev(CLOSE, 8)) < (ts_sum(CLOSE, 2) / 2)) ? (-1 * 1) : (((ts_sum(CLOSE, 2) / 2) <((ts_sum(CLOSE, 8) / 8) - stddev(CLOSE, 8))) ? 1 : (((1 < (VOLUME / MEAN(VOLUME,20))) || ((VOLUME /MEAN(VOLUME,20)) == 1)) ? 1 : (-1 * 1))))
        cond1 = ((ts_sum(self.close, 8)/8 + stddev(self.close, 8)) < ts_sum(self.close, 2)/2)
        cond2 = ((ts_sum(self.close, 8)/8 + stddev(self.close, 8)) > ts_sum(self.close, 2)/2)
        cond3 = ((ts_sum(self.close, 8)/8 + stddev(self.close, 8)) == ts_sum(self.close, 2)/2)
        cond4 = (self.volume/Mean(self.volume, 20) >= 1)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index=self.close.index)
        part[cond1] = -1
        part[cond2] = 1
        part[cond3][cond4] = 1
        part[cond3][~cond4] = -1
        
        return part
    
    def alpha_9n5(self): #1447
        ####(-1 * ts_max(correlation(ts_rank(VOLUME, 5), ts_rank(HIGH, 5), 5), 3))###
        return -1*ts_max(correlation(ts_rank(self.volume, 5),ts_rank(self.high, 5),5), 3)
    
    def alpha_9n6(self): #1779
        ####(rank(sign(delta((((OPEN * 0.85) + (HIGH * 0.15))), 4)))* -1)### 
        return -1*rank(sign(delta(((self.open * 0.85) + (self.high * 0.15)), 4)))
    
    def alpha_9n7(self): #1782
        ####((rank(MAX((VWAP - CLOSE), 3)) + rank(MIN((VWAP - CLOSE), 3))) * rank(delta(VOLUME, 3)))###
        return ((rank(Max((self.vwap - self.close), 3)) + rank(Min((self.vwap - self.close), 3))) * rank(delta(self.volume, 3)))
    
    def alpha_9n8(self): #1779
        ####rank(delta(((((HIGH + LOW) / 2) * 0.2) + (VWAP * 0.8)), 4) * -1)###    
        return rank(delta(((((self.high + self.low) / 2) * 0.2) + (self.vwap * 0.8)), 4) * -1)
    
    def alpha_9n9(self): #1790
        ####ewma(((HIGH+LOW)/2-(delay(HIGH,1)+delay(LOW,1))/2)*(HIGH-LOW)/VOLUME,7,2)###  
        return ewma(((self.high+self.low)/2-(delay(self.high,1)+delay(self.low,1))/2)*(self.high-self.low)/self.volume,7,2)
    
    def alpha_9n10(self):    
        ####(rank(MAX(((RET < 0) ? stddev(RET, 20) : CLOSE)^2),5))###
        cond = (self.returns < 0)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.returns.index)
        part[cond] = stddev(self.returns, 20)
        part[~cond] = self.close
        part = part**2
        
        return rank(Max(part, 5))
    
    def alpha_9n11(self): #1782
        ####ts_sum(((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW)*VOLUME,6)###   
        return ts_sum(((self.close-self.low)-(self.high-self.close))/(self.high-self.low)*self.volume,6)
    
    def alpha_9n12(self): #1779
        ####(rank((OPEN - (ts_sum(VWAP, 10) / 10)))) * (-1 * (rank(abs((CLOSE - VWAP)))))###   
        return (rank((self.open - (ts_sum(self.vwap, 10) / 10)))) * (-1 * (rank(abs((self.close - self.vwap)))))
    
    def alpha_9n13(self): #1790
        ####(((HIGH * LOW)^0.5) - VWAP)###
        return (((self.high * self.low)**0.5) - self.vwap)
    
    def alpha_9n14(self): #1776
        ####CLOSE-delay(CLOSE,5)###
        return self.close-delay(self.close,5)
    
    def alpha_9n15(self): #1790
        ####OPEN/delay(CLOSE,1)-1###
        return self.open/delay(self.close,1)-1
    
    def alpha_9n16(self): #1736   
        ####(-1 * ts_max(rank(correlation(rank(VOLUME), rank(VWAP), 5)), 5))###
        return (-1 * ts_max(rank(correlation(rank(self.volume), rank(self.vwap), 5)), 5))
        
    def alpha_9n17(self): #1776   
        ####rank((VWAP - MAX(VWAP, 15)))^delta(CLOSE, 5)###
        return rank((self.vwap - Max(self.vwap, 15)))**delta(self.close, 5)
    
    def alpha_9n18(self): #1776   
        ####CLOSE/delay(CLOSE,5)###
        return self.close/delay(self.close,5)  
    
    def alpha_9n19(self):  
        ####(CLOSE
        cond1 = (self.close < delay(self.close,5))
        cond2 = (self.close == delay(self.close,5))
        cond3 = (self.close > delay(self.close,5))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = (self.close-delay(self.close,5))/delay(self.close,5)
        part[cond2] = 0
        part[cond3] = (self.close-delay(self.close,5))/self.close
        
        return part
       
    def alpha_9n20(self): #1773      
        ####(CLOSE-delay(CLOSE,6))/delay(CLOSE,6)*100###
        return (self.close-delay(self.close,6))/delay(self.close,6)*100
    
    # def alpha_9n21(self):  #reg？
    #     ####REGBETA(MEAN(CLOSE,6),SEQUENCE(6))###
    #     return 0
    
    def alpha_9n22(self): #1736  
        ####ewma(((CLOSE-MEAN(CLOSE,6))/MEAN(CLOSE,6)-delay((CLOSE-MEAN(CLOSE,6))/MEAN(CLOSE,6),3)),12,1)###
        return ewma(((self.close-Mean(self.close,6))/Mean(self.close,6)-delay((self.close-Mean(self.close,6))/Mean(self.close,6),3)),12,1)
     
    def alpha_9n23(self):  
        ####ewma((CLOSE>delay(CLOSE,1)?stddev(CLOSE,20):0),20,1) / (ewma((CLOSE>delay(CLOSE,1)?stddev(CLOSE,20):0),20,1) + ewma((CLOSE<=delay(CLOSE,1)?stddev(CLOSE,20):0),20,1))*100###
        cond = (self.close > delay(self.close,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns,index =self.close.index)
        part1[cond] = stddev(self.close,20)
        part1[~cond] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = stddev(self.close,20)
        part2[cond] = 0
        
        return 100*ewma(part1,20,1)/(ewma(part1,20,1) + ewma(part2,20,1))
        
    def alpha_9n24(self): #1776  
        ####ewma(CLOSE-delay(CLOSE,5),5,1)###
        return ewma(self.close-delay(self.close,5),5,1)
    
    def alpha_9n25(self):  #886  数据量较少
        ####((-1 * rank((delta(CLOSE, 7) * (1 - rank(decay_linear((VOLUME / MEAN(VOLUME,20)), 9)))))) * (1 + rank(ts_sum(RET, 250))))###
        return ((-1 * rank((delta(self.close, 7) * (1 - rank(decay_linear((self.volume / Mean(self.volume,20)), 9)))))) * (1 + rank(ts_sum(self.returns, 250))))
    
    def alpha_9n26(self):   #平均数据量914，获得的数据量较少 
        ####((((ts_sum(CLOSE, 7) / 7) - CLOSE)) + ((correlation(VWAP, delay(CLOSE, 5), 230))))###
        return ((((ts_sum(self.close, 7) / 7) - self.close)) + ((correlation(self.vwap, delay(self.close, 5), 230))))
    
    def alpha_9n27(self):  
        ####WMA((CLOSE-delay(CLOSE,3))/delay(CLOSE,3)*100+(CLOSE-delay(CLOSE,6))/delay(CLOSE,6)*100,12)###
        A = (self.close-delay(self.close,3))/delay(self.close,3)*100+(self.close-delay(self.close,6))/delay(self.close,6)*100
        return Wma(A, 12)
    
    def alpha_9n28(self):   #1728 
        ####3*ewma((CLOSE-ts_min(LOW,9))/(ts_max(HIGH,9)-ts_min(LOW,9))*100,3,1)-2*ewma(ewma((CLOSE-ts_min(LOW,9))/(MAX(HIGH,9)-ts_max(LOW,9))*100,3,1),3,1)###
        return 3*ewma((self.close-ts_min(self.low,9))/(ts_max(self.high,9)-ts_min(self.low,9))*100,3,1)-2*ewma(ewma((self.close-ts_min(self.low,9))/(Max(self.high,9)-ts_max(self.low,9))*100,3,1),3,1)
    
    def alpha_9n29(self):   #1773 
        ####(CLOSE-delay(CLOSE,6))/delay(CLOSE,6)*VOLUME###
        return (self.close-delay(self.close,6))/delay(self.close,6)*self.volume
    
    # def alpha_9n30(self):  #reg？
    #     ####WMA((REGRESI(CLOSE/delay(CLOSE)-1,MKT,SMB,HML， 60))^2,20)###
    #     return 0
    
    def alpha_9n31(self):   #1714
        ####(CLOSE-MEAN(CLOSE,12))/MEAN(CLOSE,12)*100###
        return (self.close-Mean(self.close,12))/Mean(self.close,12)*100
    
    def alpha_9n32(self):   #1505
        ####(-1 * ts_sum(rank(correlation(rank(HIGH), rank(VOLUME), 3)), 3))###
        return (-1 * ts_sum(rank(correlation(rank(self.high), rank(self.volume), 3)), 3))
    
    def alpha_9n33(self):   #904  数据量较少
        ####((((-1 * ts_min(LOW, 5)) + delay(ts_min(LOW, 5), 5)) * rank(((ts_sum(RET, 240) - ts_sum(RET, 20)) / 220))) *ts_rank(VOLUME, 5))###
        return ((((-1 * ts_min(self.low, 5)) + delay(ts_min(self.low, 5), 5)) * rank(((ts_sum(self.returns, 240) - ts_sum(self.returns, 20)) / 220))) *ts_rank(self.volume, 5))
    
    def alpha_9n34(self):   #1714
        ####MEAN(CLOSE,12)/CLOSE###
        return Mean(self.close,12)/self.close
    
    def alpha_9n35(self):   #1790    (OPEN * 0.65) +(OPEN *0.35)有问题
        ####(MIN(rank(decay_linear(delta(OPEN, 1), 15)), rank(decay_linear(correlation((VOLUME), ((OPEN * 0.65) +(OPEN *0.35)), 17),7))) * -1)###
        return (Min2(rank(decay_linear(delta(self.open, 1), 15)), rank(decay_linear(correlation((self.volume), ((self.open * 0.65) +(self.open *0.35)), 17),7))) * -1)
     
    def alpha_9n36(self):   #1714
        ####rank(ts_sum(correlation(rank(VOLUME), rank(VWAP),6), 2))###
        return rank(ts_sum(correlation(rank(self.volume), rank(self.vwap),6 ), 2))
    
    def alpha_9n37(self):   #1713
        ####(-1 * rank(((ts_sum(OPEN, 5) * ts_sum(RET, 5)) - delay((ts_sum(OPEN, 5) * ts_sum(RET, 5)), 10))))###
        return (-1 * rank(((ts_sum(self.open, 5) * ts_sum(self.returns, 5)) - delay((ts_sum(self.open, 5) * ts_sum(self.returns, 5)), 10))))
    
    def alpha_9n38(self):  
        ####(((ts_sum(HIGH, 20) / 20) < HIGH) ? (-1 * delta(HIGH, 2)) : 0)
        cond = ((ts_sum(self.high, 20) / 20) < self.high)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1 * delta(self.high, 2)
        part[~cond] = 0
        
        return part
    
    def alpha_9n39(self):   #1666
        ####((rank(decay_linear(delta((CLOSE), 2),8)) - rank(decay_linear(correlation(((VWAP * 0.3) + (OPEN * 0.7)),ts_sum(MEAN(VOLUME,180), 37), 14), 12))) * -1)###
        return ((rank(decay_linear(delta((self.close), 2),8)) - rank(decay_linear(correlation(((self.vwap * 0.3) + (self.open * 0.7)),ts_sum(Mean(self.volume,180), 37), 14), 12))) * -1)
    
    def alpha_9n40(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:0),26)/ts_sum((CLOSE<=delay(CLOSE,1)?VOLUME:0),26)*100###
        cond = (self.close > delay(self.close,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = self.volume
        part1[~cond] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = self.volume
        part2[cond] = 0
        
        return ts_sum(part1,26)/ts_sum(part2,26)*100
    
    def alpha_9n41(self):   #1782
        ####(rank(MAX(delta((VWAP), 3), 5))* -1)###
        return (rank(Max(delta((self.vwap), 3), 5))* -1)
    
    def alpha_9n42(self):   #1399  数据量较少
        ####((-1 * rank(stddev(HIGH, 10))) * correlation(HIGH, VOLUME, 10))###
        return ((-1 * rank(stddev(self.high, 10))) * correlation(self.high, self.volume, 10))
    
    def alpha_9n43(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:(CLOSE
        cond1 = (self.close > delay(self.close,1))
        cond2 = (self.close < delay(self.close,1))
        cond3 = (self.close == delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = self.volume
        part[cond2] = -self.volume
        part[cond3] = 0
        
        return ts_sum(part,6)
    
    def alpha_9n44(self):   #1748
        ####(ts_rank(decay_linear(correlation(((LOW )), MEAN(VOLUME,10), 7), 6),4) + ts_rank(decay_linear(delta((VWAP),3), 10), 15))###
        return (ts_rank(decay_linear(correlation(((self.low)), Mean(self.volume,10), 7), 6),4) + ts_rank(decay_linear(delta((self.vwap),3), 10), 15))
    
    def alpha_9n45(self):   #1070  数据量较少
        ####(rank(delta((((CLOSE * 0.6) + (OPEN *0.4))), 1)) * rank(correlation(VWAP, MEAN(VOLUME,150), 15)))###
        return (rank(delta((((self.close * 0.6) + (self.open *0.4))), 1)) * rank(correlation(self.vwap, Mean(self.volume,150), 15)))
    
    def alpha_9n46(self):   #1630
        ####(MEAN(CLOSE,3)+MEAN(CLOSE,6)+MEAN(CLOSE,12)+MEAN(CLOSE,24))/(4*CLOSE)###
        return (Mean(self.close,3)+Mean(self.close,6)+Mean(self.close,12)+Mean(self.close,24))/(4*self.close)
    
    def alpha_9n47(self):   #1759
        ####ewma((ts_max(HIGH,6)-CLOSE)/(ts_max(HIGH,6)-ts_min(LOW,6))*100,9,1)###
        return ewma((ts_max(self.high,6)-self.close)/(ts_max(self.high,6)-ts_min(self.low,6))*100,9,1)
    
    def alpha_9n48(self):   #1657
        ####(-1*((rank(((sign((CLOSE - delay(CLOSE, 1))) + sign((delay(CLOSE, 1) - delay(CLOSE, 2)))) + sign((delay(CLOSE, 2) - delay(CLOSE, 3)))))) * ts_sum(VOLUME, 5)) / ts_sum(VOLUME, 20))###
        return (-1*((rank(((sign((self.close - delay(self.close, 1))) + sign((delay(self.close, 1) - delay(self.close, 2)))) + sign((delay(self.close, 2) - delay(self.close, 3)))))) * ts_sum(self.volume, 5)) / ts_sum(self.volume, 20))
    
    def alpha_9n49(self):  
        ####ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12) / (ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12) + ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))
        cond = ((self.high + self.low) > (delay(self.high,1) + delay(self.low,1)))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 0
        part1[~cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = 0
        part2[cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        
        return ts_sum(part1, 12) / (ts_sum(part1, 12) + ts_sum(part2, 12))
    
    def alpha_9n50(self):  
        ####ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)/(ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)+ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))-ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)/(ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)+ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))###
        cond = ((self.high + self.low) <= (delay(self.high,1) + delay(self.low,1)))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 0
        part1[~cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = 0
        part2[cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        
        return (ts_sum(part1, 12) - ts_sum(part2, 12)) / (ts_sum(part1, 12) + ts_sum(part2, 12)) 

    def alpha_9n51(self):  
        ####ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12) / (ts_sum(((HIGH+LOW)<=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12)+ts_sum(((HIGH+LOW)>=(delay(HIGH,1)+delay(LOW,1))?0:MAX(abs(HIGH-delay(HIGH,1)),abs(LOW-delay(LOW,1)))),12))###
        cond = ((self.high + self.low) <= (delay(self.high,1) + delay(self.low,1)))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 0
        part1[~cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = 0
        part2[cond] = Max2(abs(self.high - delay(self.high,1)), abs(self.low - delay(self.low,1)))
        
        return ts_sum(part1, 12) / (ts_sum(part1, 12) + ts_sum(part2, 12))
    
    def alpha_9n52(self):   #1611
        ####ts_sum(MAX(0,HIGH-delay((HIGH+LOW+CLOSE)/3,1)),26)/ts_sum(MAX(0,delay((HIGH+LOW+CLOSE)/3,1)-L),26)*100###
        return ts_sum(Max(self.high-delay((self.high+self.low+self.close)/3,1),0),26)/ts_sum(Max(delay((self.high+self.low+self.close)/3,1)-self.low, 0),26)*100
    
    def alpha_9n53(self):  
        ####COUNT(CLOSE>delay(CLOSE,1),12)/12*100###
        cond = (self.close > delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1 #把满足条件的记为1，之后统计1的个数
        part1 = ts_sum(part,12)
        return part1
    
    def alpha_9n54(self):   #1729
        ####(-1 * rank((stddev(abs(CLOSE - OPEN)) + (CLOSE - OPEN)) + correlation(CLOSE, OPEN,10)))###
        return (-1 * rank(((abs(self.close - self.open)).stddev() + (self.close - self.open)) + correlation(self.close, self.open,10)))
    
    def alpha_9n55(self):  #公式有问题
        ####ts_sum(16*(CLOSE-delay(CLOSE,1)+(CLOSE-OPEN)/2+delay(CLOSE,1)-delay(OPEN,1))/((abs(HIGH-delay(CLOSE,1))>abs(LOW-delay(CLOSE,1)) & abs(HIGH-delay(CLOSE,1))>abs(HIGH-delay(LOW,1))?abs(HIGH-delay(CLOSE,1))+abs(LOW-delay(CLOSE,1))/2 + abs(delay(CLOSE,1)-delay(OPEN,1))/4:(abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(LOW,1)) & abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(CLOSE,1))?abs(LOW-delay(CLOSE,1))+abs(HIGH-delay(CLOSE,1))/2+abs(delay(CLOSE,1)-delay(OPEN,1))/4:abs(HIGH-delay(LOW,1))+abs(delay(CLOSE,1)-delay(OPEN,1))/4)))*MAX(abs(HIGH-delay(CLOSE,1)),abs(LOW-delay(CLOSE,1))),20)
        A = abs(self.high - delay(self.close, 1))
        B = abs(self.low - delay(self.close, 1))
        C = abs(self.high - delay(self.low, 1))
        cond1 = ((A > B) & (A > C))
        cond2 = ((B > C) & (B > A))
        cond3 = ((C >= A) & (C >= B))
        part0 = 16*(self.close + (self.close - self.open)/2 - delay(self.open,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = abs(self.high - delay(self.close, 1)) + abs(self.low - delay(self.close, 1))/2 + abs(delay(self.close, 1)-delay(self.open, 1))/4
        part1[cond2] = abs(self.low - delay(self.close, 1)) + abs(self.high - delay(self.close, 1))/2 + abs(delay(self.close, 1)-delay(self.open, 1))/4
        part1[cond3] = abs(self.high - delay(self.low, 1)) + abs(delay(self.close, 1)-delay(self.open, 1))/4
        
        return ts_sum(part0/part1,20)
    
    def alpha_9n56(self):  
        ####(rank((OPEN - ts_min(OPEN, 12))) < rank((rank(correlation(ts_sum(((HIGH + LOW) / 2), 19),ts_sum(MEAN(VOLUME,40), 19), 13))^5)))###
        A = rank((self.open - ts_min(self.open, 12)))
        B = rank((rank(correlation(ts_sum(((self.high + self.low) / 2), 19),ts_sum(Mean(self.volume,40), 19), 13))**5))
        cond = (A < B)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1
        #part[~cond] = 0
        return part
    
    def alpha_9n57(self):   #1736
        ####ewma((CLOSE-ts_min(LOW,9))/(ts_max(HIGH,9)-ts_min(LOW,9))*100,3,1)###
        return ewma((self.close-ts_min(self.low,9))/(ts_max(self.high,9)-ts_min(self.low,9))*100,3,1)
    
    def alpha_9n58(self):  
        ####COUNT(CLOSE>delay(CLOSE,1),20)/20*100###

        cond = (self.close > delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1 #把满足条件的记为1，之后统计1的个数
        '''
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[0:19] = np.nan
        for i in range(20,len(part1)+1): 
            part1.iloc[i-1:i] = part.iloc[i-20:i].value_counts().get(1)
        return part1'''
        return Count(part,20)
        
    
    def alpha_9n59(self):  
        ####ts_sum((CLOSE=delay(CLOSE,1)?0:CLOSE-(CLOSE>delay(CLOSE,1)?MIN(LOW,delay(CLOSE,1)):MAX(HIGH,delay(CLOSE,1)))),20)###
        cond1 = (self.close == delay(self.close,1))
        cond2 = (self.close > delay(self.close,1))
        cond3 = (self.close < delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = 0
        part[cond2] = self.close - Min2(self.low,delay(self.close,1))
        part[cond3] = self.close - Max2(self.low,delay(self.close,1))
        
        return ts_sum(part, 20)
    
    def alpha_9n60(self):   #1635
        ####ts_sum(((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW)*VOLUME,20)###
        return ts_sum(((self.close-self.low)-(self.high-self.close))/(self.high-self.low)*self.volume,20)

    def alpha_9n61(self):   #1790
        ####(MAX(rank(decay_linear(delta(VWAP, 1), 12)),rank(decay_linear(rank(correlation((LOW),MEAN(VOLUME,80), 8)), 17))) * -1)###
        return (Max2(rank(decay_linear(delta(self.vwap, 1), 12)),rank(decay_linear(rank(correlation((self.low),Mean(self.volume,80), 8)), 17))) * -1)
    
    def alpha_9n62(self):   #1479
        ####(-1 * correlation(HIGH, rank(VOLUME), 5))###
        return (-1 * correlation(self.high, rank(self.volume), 5))
    
    def alpha_9n63(self):   #1789
        ####ewma(MAX(CLOSE-delay(CLOSE,1),0),6,1)/ewma(abs(CLOSE-delay(CLOSE,1)),6,1)*100###
        return ewma(Max(self.close-delay(self.close,1),0),6,1)/ewma(abs(self.close-delay(self.close,1)),6,1)*100
    
    def alpha_9n64(self):   #1774
        ####(MAX(rank(decay_linear(correlation(rank(VWAP), rank(VOLUME), 4), 4)),rank(decay_linear(MAX(correlation(rank(CLOSE), rank(MEAN(VOLUME,60)), 4), 13), 14))) * -1)###
        return (Max2(rank(decay_linear(correlation(rank(self.vwap), rank(self.volume), 4), 4)),rank(decay_linear(Max(correlation(rank(self.close), rank(Mean(self.volume,60)), 4), 13), 14))) * -1)
    
    def alpha_9n65(self):   #1759
        ####MEAN(CLOSE,6)/CLOSE###
        return Mean(self.close,6)/self.close
    
    def alpha_9n66(self):   #1759
        ####(CLOSE-MEAN(CLOSE,6))/MEAN(CLOSE,6)*100###
        return (self.close-Mean(self.close,6))/Mean(self.close,6)*100
    
    def alpha_9n67(self):   #1759
        ####ewma(MAX(CLOSE-delay(CLOSE,1),0),24,1)/ewma(abs(CLOSE-delay(CLOSE,1)),24,1)*100###
        return ewma(Max(self.close-delay(self.close,1),0),24,1)/ewma(abs(self.close-delay(self.close,1)),24,1)*100
    
    def alpha_9n68(self):   #1790
        ####ewma(((HIGH+LOW)/2-(delay(HIGH,1)+delay(LOW,1))/2)*(HIGH-LOW)/VOLUME,15,2)###
        return ewma(((self.high+self.low)/2-(delay(self.high,1)+delay(self.low,1))/2)*(self.high-self.low)/self.volume,15,2)
    
    def alpha_9n69(self):  
        ####(ts_sum(DTM,20)>ts_sum(DBM,20)？ (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DTM,20)： (ts_sum(DTM,20)=ts_sum(DBM,20)？0： (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DBM,20)))###
        ####DTM (OPEN<=delay(OPEN,1)?0:MAX((HIGH-OPEN),(OPEN-delay(OPEN,1))))
        ####DBM (OPEN>=delay(OPEN,1)?0:MAX((OPEN-LOW),(OPEN-delay(OPEN,1))))
        cond1 = (self.open <= delay(self.open,1))
        cond2 = (self.open >= delay(self.open,1))
        
        DTM = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        #DTM[cond1] = 0
        DTM[~cond1] = Max2((self.high-self.open),(self.open-delay(self.open,1)))
        
        DBM = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        #DBM[cond2] = 0
        DBM[~cond2] = Max2((self.open-self.low),(self.open-delay(self.open,1)))
        
        cond3 = (ts_sum(DTM,20) > ts_sum(DBM,20))
        cond4 = (ts_sum(DTM,20)== ts_sum(DBM,20))
        cond5 = (ts_sum(DTM,20) < ts_sum(DBM,20))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond3] = (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DTM,20)
        #part[cond4] = 0
        part[cond5] = (ts_sum(DTM,20)-ts_sum(DBM,20))/ts_sum(DBM,20)
        return part
    
    def alpha_9n70(self):   #1759
        ####stddev(AMOUNT,6)###
        return stddev(self.amount,6)
    
    def alpha_9n71(self):   #1630
        ####(CLOSE-MEAN(CLOSE,24))/MEAN(CLOSE,24)*100###
        return (self.close-Mean(self.close,24))/Mean(self.close,24)*100
    
    def alpha_9n72(self):   #1759
        ####ewma((ts_max(HIGH,6)-CLOSE)/(ts_max(HIGH,6)-ts_min(LOW,6))*100,15,1)###
        return ewma((ts_max(self.high,6)-self.close)/(ts_max(self.high,6)-ts_min(self.low,6))*100,15,1)
    
    def alpha_9n73(self):   #1729
        ####((ts_rank(decay_linear(decay_linear(correlation((CLOSE), VOLUME, 10), 16), 4), 5) - rank(decay_linear(correlation(VWAP, MEAN(VOLUME,30), 4),3))) * -1)###
        return ((ts_rank(decay_linear(decay_linear(correlation((self.close), self.volume, 10), 16), 4), 5) - rank(decay_linear(correlation(self.vwap, Mean(self.volume,30), 4),3))) * -1) 
    
    def alpha_9n74(self):   #1402
        ####(rank(correlation(ts_sum(((LOW * 0.35) + (VWAP * 0.65)), 20), ts_sum(MEAN(VOLUME,40), 20), 7)) + rank(correlation(rank(VWAP), rank(VOLUME), 6)))###
        return (rank(correlation(ts_sum(((self.low * 0.35) + (self.vwap * 0.65)), 20), ts_sum(Mean(self.volume,40), 20), 7)) + rank(correlation(rank(self.vwap), rank(self.volume), 6)))
    
    # def alpha_9n75(self):  
    #     ####COUNT(CLOSE>OPEN & BANCHMARKINDEXCLOSE
    #     cond1 = ((self.close>self.open)&(self.benchmark_close<self.benchmark_open))
    #     cond2 = (self.benchmark_close<self.benchmark_open)
    #     part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
    #     part1[cond1] = 1
    #     part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
    #     part2[cond2] = 1     
    #     return Count(part1,50)/Count(part2,50)
    
    def alpha_9n76(self):   #1650
        ####stddev(abs((CLOSE/delay(CLOSE,1)-1))/VOLUME,20)/MEAN(abs((CLOSE/delay(CLOSE,1)-1))/VOLUME,20)###
        return stddev(abs((self.close/delay(self.close,1)-1))/self.volume,20)/Mean(abs((self.close/delay(self.close,1)-1))/self.volume,20)
    
    def alpha_9n77(self):   #1797
        #### MIN(rank(decay_linear(((((HIGH + LOW) / 2) + HIGH) - (VWAP + HIGH)), 20)),rank(decay_linear(correlation(((HIGH + LOW) / 2), MEAN(VOLUME,40), 3), 6)))###
        return  Min2(rank(decay_linear(((((self.high + self.low) / 2) + self.high) - (self.vwap + self.high)), 20)),rank(decay_linear(correlation(((self.high + self.low) / 2), Mean(self.volume,40), 3), 6)))
       
    def alpha_9n78(self):   #1637
        ####((HIGH+LOW+CLOSE)/3-MA((HIGH+LOW+CLOSE)/3,12))/(0.015*MEAN(abs(CLOSE-MEAN((HIGH+LOW+CLOSE)/3,12)),12))###
        return ((self.high+self.low+self.close)/3-Mean((self.high+self.low+self.close)/3,12))/(0.015*Mean(abs(self.close-Mean((self.high+self.low+self.close)/3,12)),12))
    
    def alpha_9n79(self):   #1789
        ####ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100###
        return ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100
    
    def alpha_9n80(self):   #1776
        ####(VOLUME-delay(VOLUME,5))/delay(VOLUME,5)*100###
        return (self.volume-delay(self.volume,5))/delay(self.volume,5)*100
    
    def alpha_9n81(self):   #1797
        ####ewma(VOLUME,21,2)###
        return ewma(self.volume,21,2)
    
    def alpha_9n82(self):   #1759
        ####ewma((ts_max(HIGH,6)-CLOSE)/(ts_max(HIGH,6)-ts_min(LOW,6))*100,20,1)###
        return ewma((ts_max(self.high,6)-self.close)/(ts_max(self.high,6)-ts_min(self.low,6))*100,20,1)
    
    def alpha_9n83(self):   #1766
        ####(-1 * rank(COVIANCE(rank(HIGH), rank(VOLUME), 5)))###
        return (-1 * rank(covariance(rank(self.high), rank(self.volume), 5)))
    
    def alpha_9n84(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:(CLOSE
        cond1 = (self.close > delay(self.close,1))
        cond2 = (self.close < delay(self.close,1))
        cond3 = (self.close == delay(self.close,1))  
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = self.volume
        part[cond2] = 0
        part[cond3] = -self.volume 
        return ts_sum(part, 20)
    
    def alpha_9n85(self):   #1657
        ####(ts_rank((VOLUME / MEAN(VOLUME,20)), 20) * ts_rank((-1 * delta(CLOSE, 7)), 8))###
        return (ts_rank((self.volume / Mean(self.volume,20)), 20) * ts_rank((-1 * delta(self.close, 7)), 8))
    
    def alpha_9n86(self):  
        ####((0.25 < (((delay(CLOSE, 20) - delay(CLOSE, 10)) / 10) - ((delay(CLOSE, 10) - CLOSE) / 10))) ? (-1 * 1) :(((((delay(CLOSE, 20) - delay(CLOSE, 10)) / 10) - ((delay(CLOSE, 10) - CLOSE) / 10)) < 0) ?1 : ((-1 * 1) *(CLOSE - delay(CLOSE, 1)))))
        A = (((delay(self.close, 20) - delay(self.close, 10)) / 10) - ((delay(self.close, 10) - self.close) / 10))
        cond1 = (A > 0.25)
        cond2 = (A < 0.0)
        cond3 = ((0 <= A) & (A <= 0.25))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = -1
        part[cond2] = 1
        part[cond3] = -1*(self.close - delay(self.close, 1))
        return part

    def alpha_9n87(self):   #1741
        ####((rank(decay_linear(delta(VWAP, 4), 7)) + ts_rank(decay_linear(((((LOW * 0.9) + (LOW * 0.1)) - VWAP) /(OPEN - ((HIGH + LOW) / 2))), 11), 7)) * -1)###
        return ((rank(decay_linear(delta(self.vwap, 4), 7)) + ts_rank(decay_linear(((((self.low * 0.9) + (self.low * 0.1)) - self.vwap) /(self.open - ((self.high + self.low) / 2))), 11), 7)) * -1)
  
    def alpha_9n88(self):   #1745
        ####(CLOSE-delay(CLOSE,20))/delay(CLOSE,20)*100###
        return (self.close-delay(self.close,20))/delay(self.close,20)*100
    
    def alpha_9n89(self):   #1797
        ####2*(ewma(CLOSE,13,2)-ewma(CLOSE,27,2)-ewma(ewma(CLOSE,13,2)-ewma(CLOSE,27,2),10,2))###
        return 2*(ewma(self.close,13,2)-ewma(self.close,27,2)-ewma(ewma(self.close,13,2)-ewma(self.close,27,2),10,2))
    
    def alpha_9n90(self):   #1745
        ####(rank(correlation(rank(VWAP), rank(VOLUME), 5)) * -1)###
        return (rank(correlation(rank(self.vwap), rank(self.volume), 5)) * -1)
    
    def alpha_9n91(self):   #1745
        ####((rank((CLOSE - MAX(CLOSE, 5)))*rank(correlation((MEAN(VOLUME,40)), LOW, 5))) * -1)###
        return ((rank((self.close - Max(self.close, 5)))*rank(correlation((Mean(self.volume,40)), self.low, 5))) * -1)
    
    def alpha_9n92(self):   #1786
        ####(MAX(rank(decay_linear(delta(((CLOSE * 0.35) + (VWAP *0.65)), 2), 3)),ts_rank(decay_linear(abs(correlation((MEAN(VOLUME,180)), CLOSE, 13)), 5), 15)) * -1)###
        return (Max2(rank(decay_linear(delta(((self.close * 0.35) + (self.vwap *0.65)), 2), 3)),ts_rank(decay_linear(abs(correlation((Mean(self.volume,180)), self.close, 13)), 5), 15)) * -1)
    
    def alpha_9n93(self):  
        ####ts_sum((OPEN>=delay(OPEN,1)?0:MAX((OPEN-LOW),(OPEN-delay(OPEN,1)))),20)###
        cond = (self.open >= delay(self.open,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        #part[cond] = 0
        part[~cond] = Max2((self.open-self.low),(self.open-delay(self.open,1)))
        return ts_sum(part, 20)
    
    def alpha_9n94(self):  
        ####ts_sum((CLOSE>delay(CLOSE,1)?VOLUME:(CLOSE
        cond1 = (self.close > delay(self.close,1))
        cond2 = (self.close < delay(self.close,1))
        cond3 = (self.close == delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond1] = self.volume
        part[cond2] = -1*self.volume
        #part[cond3] = 0
        return ts_sum(part, 30)
    
    def alpha_9n95(self):   #1657
        ####stddev(AMOUNT,20)###
        return stddev(self.amount,20)
    
    def alpha_9n96(self):   #1736
        ####ewma(ewma((CLOSE-ts_min(LOW,9))/(ts_max(HIGH,9)-ts_min(LOW,9))*100,3,1),3,1)###
        return ewma(ewma((self.close-ts_min(self.low,9))/(ts_max(self.high,9)-ts_min(self.low,9))*100,3,1),3,1)
    
    def alpha_9n97(self):   #1729
        ####stddev(VOLUME,10)###
        return stddev(self.volume,10)
    
    def alpha_9n98(self):  
        ####((((delta((ts_sum(CLOSE, 100) / 100), 100) / delay(CLOSE, 100)) < 0.05) || ((delta((ts_sum(CLOSE, 100) / 100), 100) /delay(CLOSE, 100)) == 0.05)) ? (-1 * (CLOSE - ts_min(CLOSE, 100))) : (-1 * delta(CLOSE, 3)))###
        cond = (delta(ts_sum(self.close,100)/100, 100)/delay(self.close, 100) <= 0.05)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1 * (self.close - ts_min(self.close, 100))
        part[~cond] = -1 * delta(self.close, 3)
        return part
    
    def alpha_9n99(self):   #1766
        ####(-1 * rank(covariance(rank(self.close), rank(self.volume), 5)))###
        return (-1 * rank(covariance(rank(self.close), rank(self.volume), 5)))
    
    def alpha_9n100(self):   #1657
        ####stddev(self.volume,20)###
        return stddev(self.volume,20)
    
    def alpha_9n101(self):  
        ###((rank(correlation(CLOSE, ts_sum(MEAN(VOLUME,30), 37), 15)) < rank(correlation(rank(((HIGH * 0.1) + (VWAP * 0.9))),rank(VOLUME), 11))) * -1)
        rank1 = rank(correlation(self.close, ts_sum(Mean(self.volume,30), 37), 15))
        rank2 = rank(correlation(rank(((self.high * 0.1) + (self.vwap * 0.9))),rank(self.volume), 11))
        cond = (rank1<rank2)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1
        #part[~cond] = 0
        return part
    
    def alpha_9n102(self):   #1790
        ####ewma(MAX(VOLUME-delay(VOLUME,1),0),6,1)/ewma(abs(VOLUME-delay(VOLUME,1)),6,1)*100###
        return ewma(Max(self.volume-delay(self.volume,1),0),6,1)/ewma(abs(self.volume-delay(self.volume,1)),6,1)*100
    
    def alpha_9n103(self):  
        ####((20-LOWDAY(LOW,20))/20)*100###
        return ((20-Lowday(self.low,20))/20)*100
    
    def alpha_9n104(self):   #1657
        ####(-1 * (delta(correlation(HIGH, VOLUME, 5), 5) * rank(stddev(CLOSE, 20))))###
        return (-1 * (delta(correlation(self.high, self.volume, 5), 5) * rank(stddev(self.close, 20))))
    
    def alpha_9n105(self):   #1729
        ####(-1 * correlation(rank(OPEN), rank(VOLUME), 10))###
        return (-1 * correlation(rank(self.open), rank(self.volume), 10))
    
    def alpha_9n106(self):   #1745
        ####CLOSE-delay(CLOSE,20)###
        return self.close-delay(self.close,20)
    
    def alpha_9n107(self):   #1790
        ####(((-1 * rank((OPEN - delay(HIGH, 1)))) * rank((OPEN - delay(CLOSE, 1)))) * rank((OPEN - delay(LOW, 1))))###
        return (((-1 * rank((self.open - delay(self.high, 1)))) * rank((self.open - delay(self.close, 1)))) * rank((self.open - delay(self.low, 1))))
    
    def alpha_9n108(self):   #1178   
        ####((rank((HIGH - MIN(HIGH, 2)))^rank(correlation((VWAP), (MEAN(VOLUME,120)), 6))) * -1)###
        return ((rank((self.high - Min(self.high, 2)))**rank(correlation((self.vwap), (Mean(self.volume,120)), 6))) * -1)
    
    def alpha_9n109(self):   #1797
        ####ewma(HIGH-LOW,10,2)/ewma(ewma(HIGH-LOW,10,2),10,2)###
        return ewma(self.high-self.low,10,2)/ewma(ewma(self.high-self.low,10,2),10,2)
    
    def alpha_9n110(self):   #1650
        ####ts_sum(MAX(0,HIGH-delay(CLOSE,1)),20)/ts_sum(MAX(0,delay(CLOSE,1)-LOW),20)*100###
        return ts_sum(Max(self.high-delay(self.close,1),0),20)/ts_sum(Max(delay(self.close,1)-self.low,0),20)*100
      
    def alpha_9n111(self):   #1789
        ####ewma(VOL*((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW),11,2)-ewma(VOL*((CLOSE-LOW)-(HIGH-CLOSE))/(HIGH-LOW),4,2)###
        return ewma(self.volume*((self.close-self.low)-(self.high-self.close))/(self.high-self.low),11,2)-ewma(self.volume*((self.close-self.low)-(self.high-self.close))/(self.high-self.low),4,2)
    
    def alpha_9n112(self):  
        ####(ts_sum((CLOSE-delay(CLOSE,1)>0? CLOSE-delay(CLOSE,1):0),12) - ts_sum((CLOSE-delay(CLOSE,1)<0?abs(CLOSE-delay(CLOSE,1)):0),12))/(ts_sum((CLOSE-delay(CLOSE,1)>0?CLOSE-delay(CLOSE,1):0),12) + ts_sum((CLOSE-delay(CLOSE,1)<0?abs(CLOSE-delay(CLOSE,1)):0),12))*100     
        cond = (self.close-delay(self.close,1) > 0)
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = self.close-delay(self.close,1)
        #part1[~cond] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = abs(self.close-delay(self.close,1))
        #part2[cond] = 0
        return (ts_sum(part1,12) - ts_sum(part2,12))/(ts_sum(part1,12) + ts_sum(part2,12))*100
    
    def alpha_9n113(self):   #1587
        ####(-1 * ((rank((ts_sum(delay(CLOSE, 5), 20) / 20)) * correlation(CLOSE, VOLUME, 2)) * rank(correlation(ts_sum(CLOSE, 5),ts_sum(CLOSE, 20), 2))))###
        return (-1 * ((rank((ts_sum(delay(self.close, 5), 20) / 20)) * correlation(self.close, self.volume, 2)) * rank(correlation(ts_sum(self.close, 5),ts_sum(self.close, 20), 2))))
    
    def alpha_9n114(self):   #1751
        ####((rank(delay(((HIGH - LOW) / (ts_sum(CLOSE, 5) / 5)), 2)) * rank(rank(VOLUME))) / (((HIGH - LOW) /(ts_sum(CLOSE, 5) / 5)) / (VWAP - CLOSE)))###
        return ((rank(delay(((self.high - self.low) / (ts_sum(self.close, 5) / 5)), 2)) * rank(rank(self.volume))) / (((self.high - self.low) /(ts_sum(self.close, 5) / 5)) / (self.vwap - self.close)))
    
    def alpha_9n115(self):   #1527
        ####(rank(correlation(((HIGH * 0.9) + (CLOSE * 0.1)), MEAN(VOLUME,30), 10))^rank(correlation(ts_rank(((HIGH + LOW) /2), 4), ts_rank(VOLUME, 10), 7)))###
        return (rank(correlation(((self.high * 0.9) + (self.close * 0.1)), Mean(self.volume,30), 10))**rank(correlation(ts_rank(((self.high + self.low) /2), 4), ts_rank(self.volume, 10), 7)))
    
    # def alpha_9n116(self):  
    #     ####REGBETA(CLOSE,SEQUENCE,20)###
    #     return 0
    
    def alpha_9n117(self):   #1786
        ####((ts_rank(VOLUME, 32) * (1 - ts_rank(((CLOSE + HIGH) - LOW), 16))) * (1 - ts_rank(RET, 32)))###
        return ((ts_rank(self.volume, 32) * (1 - ts_rank(((self.close + self.high) - self.low), 16))) * (1 - ts_rank(self.returns, 32)))
    
    def alpha_9n118(self):   #1657
        ####ts_sum(HIGH-OPEN,20)/ts_sum(OPEN-LOW,20)*100###
        return ts_sum(self.high-self.open,20)/ts_sum(self.open-self.low,20)*100
    
    def alpha_9n119(self):   #1626
        ####(rank(decay_linear(correlation(VWAP, ts_sum(MEAN(VOLUME,5), 26), 5), 7)) - rank(decay_linear(ts_rank(MIN(correlation(rank(OPEN), rank(MEAN(VOLUME,15)), 21), 9), 7), 8)))###
        return (rank(decay_linear(correlation(self.vwap, ts_sum(Mean(self.volume,5), 26), 5), 7)) - rank(decay_linear(ts_rank(Min(correlation(rank(self.open), rank(Mean(self.volume,15)), 21), 9), 7), 8)))
    
    def alpha_9n120(self):   #1797
        ####(rank((VWAP - CLOSE)) / rank((VWAP + CLOSE)))###
        return (rank((self.vwap - self.close)) / rank((self.vwap + self.close)))
    
    def alpha_9n121(self):   #972   数据量较少
        ####((rank((VWAP - MIN(VWAP, 12)))^ts_rank(correlation(ts_rank(VWAP, 20), ts_rank(MEAN(VOLUME,60), 2), 18), 3)) *-1)###
        return ((rank((self.vwap - Min(self.vwap, 12)))**ts_rank(correlation(ts_rank(self.vwap, 20), ts_rank(Mean(self.volume,60), 2), 18), 3)) *-1)
    
    def alpha_9n122(self):   #1790
        ####(ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2)-delay(ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2),1))/delay(ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2),1)###
        return (ewma(ewma(ewma(log(self.close),13,2),13,2),13,2)-delay(ewma(ewma(ewma(log(self.close),13,2),13,2),13,2),1))/delay(ewma(ewma(ewma(log(self.close),13,2),13,2),13,2),1)
    
    def alpha_9n123(self):  
        ####((rank(correlation(ts_sum(((HIGH + LOW) / 2), 20), ts_sum(MEAN(VOLUME,60), 20), 9)) < rank(correlation(LOW, VOLUME,6))) * -1)###
        A = rank(correlation(ts_sum(((self.high + self.low) / 2), 20), ts_sum(Mean(self.volume,60), 20), 9))
        B = rank(correlation(self.low, self.volume,6))
        cond = (A < B)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1
        #part[~cond] = 0
        return part
    
    def alpha_9n124(self):   #1592
        ####(CLOSE - VWAP) / decay_linear(rank(ts_max(CLOSE, 30)),2)###
        return (self.close - self.vwap) / decay_linear(rank(ts_max(self.close, 30)),2)
     
    def alpha_9n125(self):   #1678
        ####(rank(decay_linear(correlation((VWAP), MEAN(VOLUME,80),17), 20)) / rank(decay_linear(delta(((CLOSE * 0.5) + (VWAP * 0.5)), 3), 16)))###
        return (rank(decay_linear(correlation((self.vwap), Mean(self.volume,80),17), 20)) / rank(decay_linear(delta(((self.close * 0.5) + (self.vwap * 0.5)), 3), 16)))
    
    def alpha_9n126(self):   #1797
        ####(CLOSE+HIGH+LOW)/3###
        return (self.close+self.high+self.low)/3
    
    def alpha_9n127(self):  #公式有问题，我们假设mean周期为12
        ####(MEAN((100*(CLOSE-MAX(CLOSE,12))/(MAX(CLOSE,12)))^2),12)^(1/2)###
        return (Mean((100*(self.close-Max(self.close,12))/(Max(self.close,12)))**2,12))**(1/2)
    
    def alpha_9n128(self):  
        ####100-(100/(1+ts_sum(((HIGH+LOW+CLOSE)/3>delay((HIGH+LOW+CLOSE)/3,1)?(HIGH+LOW+CLOSE)/3*VOLUME:0),14)/ts_sum(((HIGH+LOW+CLOSE)/3
        A = (self.high+self.low+self.close)/3
        cond = (A > delay(A,1))        
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = A*self.volume
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = A*self.volume
        return 100-(100/(1+ts_sum(part1,14)/ts_sum(part2,14)))

    def alpha_9n129(self):  
        ####ts_sum((CLOSE-delay(CLOSE,1)<0?abs(CLOSE-delay(CLOSE,1)):0),12)###
        cond = ((self.close-delay(self.close,1)) < 0)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = abs(self.close-delay(self.close,1))
        #part[~cond] = 0
        return ts_sum(part, 12)
    
    def alpha_9n130(self):   #1657
        ####(rank(decay_linear(correlation(((HIGH + LOW) / 2), MEAN(VOLUME,40), 9), 10)) / rank(decay_linear(correlation(rank(VWAP), rank(VOLUME), 7),3)))###
        return (rank(decay_linear(correlation(((self.high + self.low) / 2), Mean(self.volume,40), 9), 10)) / rank(decay_linear(correlation(rank(self.vwap), rank(self.volume), 7),3)))
    
    def alpha_9n131(self):   #1030   数据量较少
        ####(rank(DELAT(VWAP, 1))^ts_rank(correlation(CLOSE,MEAN(VOLUME,50), 18), 18))###
        return (rank(delta(self.vwap, 1))**ts_rank(correlation(self.close,Mean(self.volume,50), 18), 18))
       
    def alpha_9n132(self):   #1657
        ####MEAN(AMOUNT,20)###
        return Mean(self.amount,20)
    
    def alpha_9n133(self):  
        ####((20-HIGHDAY(HIGH,20))/20)*100-((20-LOWDAY(LOW,20))/20)*100###
        return ((20-Highday(self.high,20))/20)*100-((20-Lowday(self.low,20))/20)*100
    
    def alpha_9n134(self):   #1760
        ####(CLOSE-delay(CLOSE,12))/delay(CLOSE,12)*VOLUME###
        return (self.close-delay(self.close,12))/delay(self.close,12)*self.volume
    
    def alpha_9n135(self):   #1744
        ####ewma(delay(CLOSE/delay(CLOSE,20),1),20,1)###
        return ewma(delay(self.close/delay(self.close,20),1),20,1)
    
    def alpha_9n136(self):   #1729
        ####((-1 * rank(delta(RET, 3))) * correlation(OPEN, VOLUME, 10))###
        return ((-1 * rank(delta(self.returns, 3))) * correlation(self.open, self.volume, 10))
    
    def alpha_9n137(self):  
        ####16*(CLOSE-delay(CLOSE,1)+(CLOSE-OPEN)/2+delay(CLOSE,1)-delay(OPEN,1))/((abs(HIGH-delay(CLOSE,1))>abs(LOW-delay(CLOSE,1)) & abs(HIGH-delay(CLOSE,1))>abs(HIGH-delay(LOW,1))?abs(HIGH-delay(CLOSE,1))+abs(LOW-delay(CLOSE,1))/2+abs(delay(CLOSE,1)-delay(OPEN,1))/4:(abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(LOW,1)) & abs(LOW-delay(CLOSE,1))>abs(HIGH-delay(CLOSE,1))?abs(LOW-delay(CLOSE,1))+abs(HIGH-delay(CLOSE,1))/2+abs(delay(CLOSE,1)-delay(OPEN,1))/4:abs(HIGH-delay(LOW,1))+abs(delay(CLOSE,1)-delay(OPEN,1))/4)))*MAX(abs(HIGH-delay(CLOSE,1)),abs(LOW-delay(CLOSE,1)))
        A = abs(self.high- delay(self.close,1))
        B = abs(self.low - delay(self.close,1))
        C = abs(self.high- delay(self.low,1))
        D = abs(delay(self.close,1)-delay(self.open,1))          
        cond1 = ((A>B) & (A>C))
        cond2 = ((B>C) & (B>A))
        cond3 = ((C>=A) & (C>=B))       
        part0 = 16*(self.close + (self.close - self.open)/2 - delay(self.open,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = A + B/2 + D/4
        part1[cond2] = B + A/2 + D/4
        part1[cond3] = C + D/4     
        return part0/part1*Max2(A,B)

    def alpha_9n138(self):   #1448
        ####((rank(decay_linear(delta((((LOW * 0.7) + (VWAP *0.3))), 3), 20)) - ts_rank(decay_linear(ts_rank(correlation(ts_rank(LOW, 8), ts_rank(MEAN(VOLUME,60), 17), 5), 19), 16), 7)) * -1)###
        return ((rank(decay_linear(delta((((self.low * 0.7) + (self.vwap *0.3))), 3), 20)) - ts_rank(decay_linear(ts_rank(correlation(ts_rank(self.low, 8), ts_rank(Mean(self.volume,60), 17), 5), 19), 16), 7)) * -1)
    
    def alpha_9n139(self):   #1729
        ####(-1 * correlation(OPEN, VOLUME, 10))###
        return (-1 * correlation(self.open, self.volume, 10))
    
    def alpha_9n140(self):   #1797
        ####MIN(rank(decay_linear(((rank(OPEN) + rank(LOW)) - (rank(HIGH) + rank(CLOSE))), 8)), ts_rank(decay_linear(correlation(ts_rank(CLOSE, 8), ts_rank(MEAN(VOLUME,60), 20), 8), 7), 3))###
        return Min2(rank(decay_linear(((rank(self.open) + rank(self.low)) - (rank(self.high) + rank(self.close))), 8)), ts_rank(decay_linear(correlation(ts_rank(self.close, 8), ts_rank(Mean(self.volume,60), 20), 8), 7), 3))
    
    def alpha_9n141(self):   #1637
        ####(rank(correlation(rank(HIGH), rank(MEAN(VOLUME,15)), 9))* -1)###
        return (rank(correlation(rank(self.high), rank(Mean(self.volume,15)), 9))* -1)
    
    def alpha_9n142(self):   #1657
        ####(((-1 * rank(ts_rank(CLOSE, 10))) * rank(delta(delta(CLOSE, 1), 1))) * rank(ts_rank((VOLUME/MEAN(VOLUME,20)), 5)))###
        return (((-1 * rank(ts_rank(self.close, 10))) * rank(delta(delta(self.close, 1), 1))) * rank(ts_rank((self.volume/Mean(self.volume,20)), 5)))
    
    # def alpha_9n143(self):  
    #     ####CLOSE>delay(CLOSE,1)?(CLOSE-delay(CLOSE,1))/delay(CLOSE,1)*SELF:SELF###
    #     return 0
    
    def alpha_9n144(self):  
        ####SUMIF(abs(CLOSE/delay(CLOSE,1)-1)/AMOUNT,20,CLOSE
        cond = (self.close<delay(self.close,1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = abs(self.close/delay(self.close,1)-1)/self.amount
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[cond] = 1
        return Sumif(part1,20)/Count(part2,20)
    
    def alpha_9n145(self):   #1617
        ####(MEAN(VOLUME,9)-MEAN(VOLUME,26))/MEAN(VOLUME,12)*100###
        return (Mean(self.volume,9)-Mean(self.volume,26))/Mean(self.volume,12)*100
    
    def alpha_9n146(self):   #1650  公式有问题
        ####MEAN((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-ewma((CLOSE-delay(CLOSE,1))/delay(CLOSE,1),61,2),20)*((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-ewma((CLOSE-delay(CLOSE,1))/delay(CLOSE,1),61,2))/ewma(((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-((CLOSE-delay(CLOSE,1))/delay(CLOSE,1)-ewma((CLOSE-delay(CLOSE,1))/delay(CLOSE,1),61,2)))^2,61,2)###
        return Mean((self.close-delay(self.close,1))/delay(self.close,1)-ewma((self.close-delay(self.close,1))/delay(self.close,1),61,2),20)*((self.close-delay(self.close,1))/delay(self.close,1)-ewma((self.close-delay(self.close,1))/delay(self.close,1),61,2))/ewma(((self.close-delay(self.close,1))/delay(self.close,1)-((self.close-delay(self.close,1))/delay(self.close,1)-ewma((self.close-delay(self.close,1))/delay(self.close,1),61,2)))**2,61,2)

    # def alpha_9n147(self):  
    #     ####REGBETA(MEAN(CLOSE,12),SEQUENCE(12))###
    #     return 0
    
    def alpha_9n148(self):  
        ####((rank(correlation((OPEN), ts_sum(MEAN(VOLUME,60), 9), 6)) < rank((OPEN - ts_min(OPEN, 14)))) * -1)###
        cond = (rank(correlation((self.open), ts_sum(Mean(self.volume,60), 9), 6)) < rank((self.open - ts_min(self.open, 14))))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = -1
        #part[~cond] = 0
        return part
    
    # def alpha_9n149(self):  
    #     ####REGBETA(FILTER(CLOSE/delay(CLOSE,1)-1,BANCHMARKINDEXCLOSE
        # return 0
    
    def alpha_9n150(self):   #1797
        ####(CLOSE+HIGH+LOW)/3*VOLUME###
        return (self.close+self.high+self.low)/3*self.volume
    
    def alpha_9n151(self):   #1745
        ####ewma(CLOSE-delay(CLOSE,20),20,1)###
        return ewma(self.close-delay(self.close,20),20,1)
    
    def alpha_9n152(self):   #1559
        ####ewma(MEAN(delay(ewma(delay(CLOSE/delay(CLOSE,9),1),9,1),1),12)-MEAN(delay(ewma(delay(CLOSE/delay(CLOSE,9),1),9,1),1),26),9,1)###
        return ewma(Mean(delay(ewma(delay(self.close/delay(self.close,9),1),9,1),1),12)-Mean(delay(ewma(delay(self.close/delay(self.close,9),1),9,1),1),26),9,1)
    
    def alpha_9n153(self):   #1630
        ####(MEAN(CLOSE,3)+MEAN(CLOSE,6)+MEAN(CLOSE,12)+MEAN(CLOSE,24))/4###
        return (Mean(self.close,3)+Mean(self.close,6)+Mean(self.close,12)+Mean(self.close,24))/4
    
    def alpha_9n154(self):  
        ####(((VWAP - MIN(VWAP, 16))) < (correlation(VWAP, MEAN(VOLUME,180), 18)))###
        cond = (((self.vwap - Min(self.vwap, 16))) < (correlation(self.vwap, Mean(self.volume,180), 18)))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1
        return part
    
    def alpha_9n155(self):   #1797
        ####ewma(VOLUME,13,2)-ewma(VOLUME,27,2)-ewma(ewma(VOLUME,13,2)-ewma(VOLUME,27,2),10,2)###
        return ewma(self.volume,13,2)-ewma(self.volume,27,2)-ewma(ewma(self.volume,13,2)-ewma(self.volume,27,2),10,2)
    
    def alpha_9n156(self):   #1776
        ####(MAX(rank(decay_linear(delta(VWAP, 5), 3)), rank(decay_linear(((delta(((OPEN * 0.15) + (LOW *0.85)),2) / ((OPEN * 0.15) + (LOW * 0.85))) * -1), 3))) * -1)###
        return (Max2(rank(decay_linear(delta(self.vwap, 5), 3)), rank(decay_linear(((delta(((self.open * 0.15) + (self.low *0.85)),2) / ((self.open * 0.15) + (self.low * 0.85))) * -1), 3))) * -1)
    
    def alpha_9n157(self):   #1764
        ####(MIN(product(rank(rank(log(ts_sum(ts_min(rank(rank((-1 * rank(delta((CLOSE - 1), 5))))), 2), 1)))), 1), 5) + ts_rank(delay((-1 * RET), 6), 5))###
        return (Min(product(rank(rank(log(ts_sum(ts_min(rank(rank((-1 * rank(delta((self.close - 1), 5))))), 2), 1)))), 1), 5) + ts_rank(delay((-1 * self.returns), 6), 5))
    
    def alpha_9n158(self):   #1797
        ####((HIGH-ewma(CLOSE,15,2))-(LOW-ewma(CLOSE,15,2)))/CLOSE###
        return ((self.high-ewma(self.close,15,2))-(self.low-ewma(self.close,15,2)))/self.close
    
    def alpha_9n159(self):   #1630
        ####((CLOSE-ts_sum(MIN(LOW,delay(CLOSE,1)),6))/ts_sum(MAX(HGIH,delay(CLOSE,1))-MIN(LOW,delay(CLOSE,1)),6)*12*24+(CLOSE-ts_sum(MIN(LOW,delay(CLOSE,1)),12))/ts_sum(MAX(HGIH,delay(CLOSE,1))-MIN(LOW,delay(CLOSE,1)),12)*6*24+(CLOSE-ts_sum(MIN(LOW,delay(CLOSE,1)),24))/ts_sum(MAX(HGIH,delay(CLOSE,1))-MIN(LOW,delay(CLOSE,1)),24)*6*24)*100/(6*12+6*24+12*24)###
        return ((self.close-ts_sum(Min2(self.low,delay(self.close,1)),6))/ts_sum(Max2(self.high,delay(self.close,1))-Min2(self.low,delay(self.close,1)),6)*12*24+(self.close-ts_sum(Min2(self.low,delay(self.close,1)),12))/ts_sum(Max2(self.high,delay(self.close,1))-Min2(self.low,delay(self.close,1)),12)*6*24+(self.close-ts_sum(Min2(self.low,delay(self.close,1)),24))/ts_sum(Max2(self.high,delay(self.close,1))-Min2(self.low,delay(self.close,1)),24)*6*24)*100/(6*12+6*24+12*24)
    
    def alpha_9n160(self):  
        ####ewma((CLOSE<=delay(CLOSE,1)?stddev(CLOSE,20):0),20,1)###
        cond = (self.close<=delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = stddev(self.close,20)
        #part[~cond] = 0
        return ewma(part, 20, 1)
    
    def alpha_9n161(self):   #1714
        ####MEAN(MAX(MAX((HIGH-LOW),abs(delay(CLOSE,1)-HIGH)),abs(delay(CLOSE,1)-LOW)),12)###
        return Mean(Max2(Max2((self.high-self.low),abs(delay(self.close,1)-self.high)),abs(delay(self.close,1)-self.low)),12)
    
    def alpha_9n162(self):   #1789
        ####(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100-MIN(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100,12))/(MAX(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100,12)-MIN(ewma(MAX(CLOSE-delay(CLOSE,1),0),12,1)/ewma(abs(CLOSE-delay(CLOSE,1)),12,1)*100,12))###
        return (ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100-Min(ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100,12))/(ewma(ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100,12,1)-Min(ewma(Max(self.close-delay(self.close,1),0),12,1)/ewma(abs(self.close-delay(self.close,1)),12,1)*100,12))
    
    def alpha_9n163(self):   #1657
        ####rank(((((-1 * RET) * MEAN(VOLUME,20)) * VWAP) * (HIGH - CLOSE)))###
        return rank(((((-1 * self.returns) * Mean(self.volume,20)) * self.vwap) * (self.high - self.close)))
    
    def alpha_9n164(self):  
        ####ewma(( ((CLOSE>delay(CLOSE,1))?1/(CLOSE-delay(CLOSE,1)):1) - MIN( ((CLOSE>delay(CLOSE,1))?1/(CLOSE-delay(CLOSE,1)):1) ,12) )/(HIGH-LOW)*100,13,2)###
        cond = (self.close>delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 1/(self.close-delay(self.close,1))
        part[~cond] = 1
        return ewma((part - Min(part,12))/(self.high-self.low)*100, 13, 2)
    
    # def alpha_9n165(self):  
    #     ####MAX(SUMAC(CLOSE-MEAN(CLOSE,48)))-MIN(SUMAC(CLOSE-MEAN(CLOSE,48)))/stddev(CLOSE,48)###
        
    #     return 0
    
    # def alpha_9n166(self):  #公式有问题
        
    #     return 0

    def alpha_9n167(self):  
        ####ts_sum((CLOSE-delay(CLOSE,1)>0?CLOSE-delay(CLOSE,1):0),12)###
        cond = (self.close > delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = self.close-delay(self.close,1)
        #part[~cond] = 0
        return ts_sum(part,12)
    
    def alpha_9n168(self):   #1657
        ####(-1*VOLUME/MEAN(VOLUME,20))###
        return (-1*self.volume/Mean(self.volume,20))
    
    def alpha_9n169(self):   #1610
        ####ewma(MEAN(delay(ewma(CLOSE-delay(CLOSE,1),9,1),1),12)-MEAN(delay(ewma(CLOSE-delay(CLOSE,1),9,1),1),26),10,1)###
        return ewma(Mean(delay(ewma(self.close-delay(self.close,1),9,1),1),12)-Mean(delay(ewma(self.close-delay(self.close,1),9,1),1),26),10,1)
    
    def alpha_9n170(self):   #1657
        ####((((rank((1 / CLOSE)) * VOLUME) / MEAN(VOLUME,20)) * ((HIGH * rank((HIGH - CLOSE))) / (ts_sum(HIGH, 5) /5))) - rank((VWAP - delay(VWAP, 5))))###
        return ((((rank((1 / self.close)) * self.volume) / Mean(self.volume,20)) * ((self.high * rank((self.high - self.close))) / (ts_sum(self.high, 5) /5))) - rank((self.vwap - delay(self.vwap, 5))))
   
    def alpha_9n171(self):   #1789
        ####((-1 * ((LOW - CLOSE) * (OPEN^5))) / ((CLOSE - HIGH) * (CLOSE^5)))###
        return ((-1 * ((self.low - self.close) * (self.open**5))) / ((self.close - self.high) * (self.close**5)))
    
    def alpha_9n172(self):  
        ####MEAN(abs(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)-ts_sum((HD>0 &HD>LD)?HD:0,14)*100/ts_sum(TR,14))/(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)+ts_sum((HD>0 &HD>LD)?HD:0,14)*100/ts_sum(TR,14))*100,6)
        TR = Max2(Max2(self.high-self.low,abs(self.high-delay(self.close,1))),abs(self.low-delay(self.close,1)))
        HD = self.high-delay(self.high,1)
        LD = delay(self.low,1)-self.low
        cond1 = ((LD>0) & (LD>HD))
        cond2 = ((HD>0) & (HD>LD)) 
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = LD
        #part1[~cond1] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[cond2] = HD
        #part2[~cond2] = 0
        return Mean(abs(ts_sum(part1,14)*100/ts_sum(TR,14)-ts_sum(part2,14)*100/ts_sum(TR,14))/(ts_sum(part1,14)*100/ts_sum(TR,14)+ts_sum(part2,14)*100/ts_sum(TR,14))*100,6)
    
    def alpha_9n173(self):   #1797
        ####3*ewma(CLOSE,13,2)-2*ewma(ewma(CLOSE,13,2),13,2)+ewma(ewma(ewma(log(CLOSE),13,2),13,2),13,2)###
        return 3*ewma(self.close,13,2)-2*ewma(ewma(self.close,13,2),13,2)+ewma(ewma(ewma(log(self.close),13,2),13,2),13,2)
    
    def alpha_9n174(self):  
        ####ewma((CLOSE>delay(CLOSE,1)?stddev(CLOSE,20):0),20,1)###
        cond = (self.close>delay(self.close,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = stddev(self.close,20)
        #part[~cond] = 0
        return ewma(part,20,1)
    
    def alpha_9n175(self):   #1759
        ####MEAN(MAX(MAX((HIGH-LOW),abs(delay(CLOSE,1)-HIGH)),abs(delay(CLOSE,1)-LOW)),6)###
        return Mean(Max2(Max2((self.high-self.low),abs(delay(self.close,1)-self.high)),abs(delay(self.close,1)-self.low)),6)
    
    def alpha_9n176(self):   #1678
        ####correlation(rank(((CLOSE - ts_min(LOW, 12)) / (ts_max(HIGH, 12) - ts_min(LOW,12)))), rank(VOLUME), 6)###
        return correlation(rank(((self.close - ts_min(self.low, 12)) / (ts_max(self.high, 12) - ts_min(self.low,12)))), rank(self.volume), 6)
    
    def alpha_9n177(self):  
        ####((20-HIGHDAY(HIGH,20))/20)*100###
        return ((20-Highday(self.high,20))/20)*100
    
    def alpha_9n178(self):   #1790
        ####(CLOSE-delay(CLOSE,1))/delay(CLOSE,1)*VOLUME###
        return (self.close-delay(self.close,1))/delay(self.close,1)*self.volume
    
    def alpha_9n179(self):   #1421   数据量较少
        ####(rank(correlation(VWAP, VOLUME, 4)) *rank(correlation(rank(LOW), rank(MEAN(VOLUME,50)), 12)))###
        return (rank(correlation(self.vwap, self.volume, 4)) *rank(correlation(rank(self.low), rank(Mean(self.volume,50)), 12)))
    
    def alpha_9n180(self):  #指标有问题
        ####((MEAN(VOLUME,20) < VOLUME) ? ((-1 * ts_rank(abs(delta(CLOSE, 7)), 60)) * sign(delta(CLOSE, 7)) : (-1 *VOLUME)))
        cond = (Mean(self.volume,20) < self.volume)
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = (-1 * ts_rank(abs(delta(self.close, 7)), 60)) * sign(delta(self.close, 7)) 
        part[~cond] = -1 * self.volume
        return part
    
    def alpha_9n181(self):   #1532  公式有问题，假设后面的sum周期为20
        ####ts_sum(((CLOSE/delay(CLOSE,1)-1)-MEAN((CLOSE/delay(CLOSE,1)-1),20))-(BANCHMARKINDEXCLOSE-MEAN(BANCHMARKINDEXCLOSE,20))^2,20)/ts_sum((BANCHMARKINDEXCLOSE-MEAN(BANCHMARKINDEXCLOSE,20))^3)###
        return ts_sum(((self.close/delay(self.close,1)-1)-Mean((self.close/delay(self.close,1)-1),20))-(self.benchmark_close-Mean(self.benchmark_close,20))**2,20)/ts_sum(((self.benchmark_close-Mean(self.benchmark_close,20))**3),20)
    
    # def alpha_9n182(self):  
    #     ####COUNT((CLOSE>OPEN & BANCHMARKINDEXCLOSE>BANCHMARKINDEXOPEN)OR(CLOSE
    #     cond1 = ((self.close>self.open) & (self.benchmark_close>self.benchmark_open))
    #     cond2 = ((self.close<self.open) & (self.benchmark_close<self.benchmark_open))
    #     part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
    #     part[cond1] = 1
    #     part[cond2] = 1
    #     return Count(part,20)/20
    
    # def alpha_9n183(self):  
    #     ####MAX(SUMAC(CLOSE-MEAN(CLOSE,24)))-MIN(SUMAC(CLOSE-MEAN(CLOSE,24)))/stddev(CLOSE,24)###
    #     return 0
    
    def alpha_9n184(self):   #983   数据量较少
        ####(rank(correlation(delay((OPEN - CLOSE), 1), CLOSE, 200)) + rank((OPEN - CLOSE)))###
        return (rank(correlation(delay((self.open - self.close), 1), self.close, 200)) + rank((self.open - self.close)))
    
    def alpha_9n185(self):   #1797
        ####rank((-1 * ((1 - (OPEN / CLOSE))^2)))###
        return rank((-1 * ((1 - (self.open / self.close))**2)))
    
    def alpha_9n186(self):  
        ####(MEAN(abs(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)-ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))/(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)+ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))*100,6)+delay(MEAN(abs(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)-ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))/(ts_sum((LD>0 & LD>HD)?LD:0,14)*100/ts_sum(TR,14)+ts_sum((HD>0 & HD>LD)?HD:0,14)*100/ts_sum(TR,14))*100,6),6))/2
        TR = Max2(Max2(self.high-self.low,abs(self.high-delay(self.close,1))),abs(self.low-delay(self.close,1)))
        HD = self.high-delay(self.high,1)
        LD = delay(self.low,1)-self.low
        cond1 = ((LD>0) & (LD>HD))
        cond2 = ((HD>0) & (HD>LD)) 
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond1] = LD
        #part1[~cond1] = 0
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[cond2] = HD
        #part2[~cond2] = 0
        return (Mean(abs(ts_sum(part1,14)*100/ts_sum(TR,14)-ts_sum(part2,14)*100/ts_sum(TR,14))/(ts_sum(part1,14)*100/ts_sum(TR,14)+ts_sum(part2,14)*100/ts_sum(TR,14))*100,6)+delay(Mean(abs(ts_sum(part1,14)*100/ts_sum(TR,14)-ts_sum(part2,14)*100/ts_sum(TR,14))/(ts_sum(part1,14)*100/ts_sum(TR,14)+ts_sum(part2,14)*100/ts_sum(TR,14))*100,6),6))/2
    
    def alpha_9n187(self):  
        ####ts_sum((OPEN<=delay(OPEN,1)?0:MAX((HIGH-OPEN),(OPEN-delay(OPEN,1)))),20)###
        cond = (self.open<=delay(self.open,1))
        part = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part[cond] = 0
        part[~cond] = Max2((self.high-self.open),(self.open-delay(self.open,1)))
        return ts_sum(part,20) 
    
    def alpha_9n188(self):   #1797
        ####((HIGH-LOW–ewma(HIGH-LOW,11,2))/ewma(HIGH-LOW,11,2))*100###
        return ((self.high-self.low-ewma(self.high-self.low,11,2))/ewma(self.high-self.low,11,2))*100
    
    def alpha_9n189(self):   #1721
        ####MEAN(abs(CLOSE-MEAN(CLOSE,6)),6)###
        return Mean(abs(self.close-Mean(self.close,6)),6)
    
    # def alpha_9n190(self):  #公式有大问题,
        ####log((COUNT( CLOSE/delay(CLOSE,1)>((CLOSE/delay(CLOSE,19))^(1/20)-1) ,20)-1)*(SUMIF((CLOSE/delay(CLOSE,1)-((CLOSE/delay(CLOSE,19))^(1/20)-1))^2,20,CLOSE/delay(CLOSE,1)<(CLOSE/delay(CLOSE,19))^(1/20)-1))/((COUNT((CLOSE/delay(CLOSE,1)<(CLOSE/delay(CLOSE,19))^(1/20)-1),20))*(SUMIF((CLOSE/delay(CLOSE,1)-((CLOSE/delay(CLOSE,19))^(1/20)-1))^2,20,CLOSE/delay(CLOSE,1)>(CLOSE/delay(CLOSE,19))^(1/20)-1))))
        '''
        cond = ((self.close/delay(self.close,1)) > ((self.close/delay(self.close,19))**(1/20)-1))
        part1 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part1[cond] = 1 #COUNT
        part2 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part2[~cond] = (self.close/delay(self.close,1)-((self.close/delay(self.close,19))**(1/20)-1))**2#SUMIF
        part3 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part3[~cond] = 1 #COUNT
        part4 = pd.DataFrame(np.zeros(self.close.shape), columns=self.close.columns, index =self.close.index)
        part4[cond] = (self.close/delay(self.close,1)-((self.close/delay(self.close,19))**(1/20)-1))**2#SUMIF
        return log((Count(part1,20))*Sumif(part2,20)/(Count(part3,20)*Sumif(part4,20)))'''
        # return 0
    
    def alpha_9n191(self):   #1721
        ####((correlation(MEAN(VOLUME,20), LOW, 5) + ((HIGH + LOW) / 2)) - CLOSE)###
        return ((correlation(Mean(self.volume,20), self.low, 5) + ((self.high + self.low) / 2)) - self.close)

            